【发布时间】:2020-04-15 00:53:55
【问题描述】:
如你所知,ggplot2中有很多主题,如theme_economist、theme_minimal、theme_tufte等。
例如,我想将此代码添加到我的可视化中:
theme_economist(axis.text.x = element_text(angle = 90))
但我收到“未使用的参数”错误,因为我只能将此参数添加到主题函数。
您可以简单地使用以下代码:
ggplot(mtcars,aes(x=mpg)) + geom_histogram(binwidth=5) + theme_economist()
你有什么建议吗?
提前致谢。
【问题讨论】:
-
为什么不
ggplot(mtcars,aes(x=mpg)) + geom_histogram(binwidth=5) + theme_economist() + theme(axis.text.x = element_text(angle = 90)) -
或
your_theme <- function(...) theme_economist() + theme(...)。然后做your_plot + your_theme(axis.text.x = element_text(angle = 90))