相关疑难解决方法(0)

复制和修改默认主题

我想创建一个ggplot基于的新主题theme_bw().

我想以下步骤是必要的(在伪代码中):

  1. 制作theme_bw()的副本: theme_new() <- theme_bw()
  2. 修改副本: theme_update(axis.title.x = theme_text(family = base_family, size = base_size, vjust = 0.5))

任何关于如何实现这一点的建议将非常感谢!


编辑: @Andrie,我根据自己的需要修改了你的答案:

theme_new <- theme_set(theme_bw())
theme_new <- theme_update(axis.title.x = theme_text(family = base_family, size = base_size, vjust = 0.5))
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误:

ggplot(mtcars, aes(factor(cyl))) + geom_bar()
Run Code Online (Sandbox Code Playgroud)

匹配错误(gparname,names(gpars)):找不到对象'base_size'


编辑: 2017年10月31日,由@Andrie提供的答案工作得很好. R版本3.4.1,ggplot2_2.2.1

plot themes r ggplot2

30
推荐指数
4
解决办法
8268
查看次数

标签 统计

ggplot2 ×1

plot ×1

r ×1

themes ×1