ggthemr介绍
ggthemr为ggplot2提供了多种主题,可以直接使用,也可以根据需要设置配色,或修改参数,改变图表展示细节。下图为几个ggthemr主题案例图,更多介绍可参考GitHub主页:https://github.com/cttobin/ggthemr#installation
R语言演示
下面我们使用iris默认数据集,对ggthemr的使用进行演示。
devtools::install_github('cttobin/ggthemr')
library(ggthemr)
library(ggplot2)
# choose theme "grape"
ggthemr('grape')
ggplot(iris,aes(x=Sepal.Length,fill=Species))+geom_density(alpha=.8)+ theme(legend.position="top")
ggthemr('grape',type = "outer", layout = "scientific")
ggplot(iris,aes(x=Sepal.Length,fill=Species))+geom_density(alpha=.8)+ theme(legend.position="top")
可以看出,type参数使得背景颜色范围发生了改变,layout改变了网格线的展示情况,layout参数的可选范围包括:clean, scientific, plain, clear, minimal, pastel。其他可设置的参数还包括:spacing,text_size,pos等。
ggthemr_reset()