我想創建一個基於theme_bw()
的ggplot
的新主題。複製和修改默認主題
我想象下面的步驟是必須的(在僞代碼):
- 製作)theme_bw的副本(:
theme_new() <- theme_bw()
- 修改副本:如何
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))
不過,我得到以下錯誤:
ggplot(mtcars, aes(factor(cyl))) + geom_bar()
Error in match(gparname, names(gpars)) : object 'base_size' not found
編輯: 31/10/2017,@Andrie提供的答案工作得很好。 [R版本3.4.1,ggplot2_2.2.1
謝謝,這工作!我以前試過,但我沒有弄清楚'base_size = base_size,base_family = base_family'部分,並且總是得到錯誤'匹配錯誤(gparname,names(gpars)):object'base_size'not found'。 – donodarazao
注意:這與ggplot2 0.9中引入的新主題系統現在是多餘的。 – baptiste
[鏈接描述新的主題系統並描述如何修改它。](https://github.com/wch/ggplot2/wiki/New-theme-system) – Gregor