如何使用变量更改主题?
library(ggplot2)
ggplot(iris,aes(Sepal.Length,Petal.Width))+
geom_point()
Run Code Online (Sandbox Code Playgroud)
我可以
ggplot(iris,aes(Sepal.Length,Petal.Width))+
geom_point()+
theme_bw()
Run Code Online (Sandbox Code Playgroud)
相反,如果我的主题是在变量中定义的,
var1 <- "theme_bw"
var2 <- "theme_grey"
Run Code Online (Sandbox Code Playgroud)
我可以用它来设置主题吗?
小智 3
Theme <\xe2\x80\x93 "theme_bw()" \neval(parse(text=as.character(Theme)))\nRun Code Online (Sandbox Code Playgroud)\n\n这是另一种方法,因为我在使用 get 时遇到错误。
\n| 归档时间: |
|
| 查看次数: |
518 次 |
| 最近记录: |