
ggthemr包提供了一种快速简便的方法来完全更改ggplot2图形的外观,并根据自己的调色板快速创建主题。
ggthemr做了一个 初始化函数,当初始化函数设定主题方案以后,之后的图表不需要重复更改主题就会默认使用ggthemr的主题。这是因为初始化主题的时候,该主题就已经替换到了ggplot使用的默认标度和主题方案,极大提升作图效率。
#install
devtools :: install_github('cttobin / ggthemr' )如使用ggplot画三种不同的图。当导入ggthemr的主题时,全部替代了之前的主题。
# Define a set of figures to play with using the Iris dataset
point_plot <- ggplot(iris, aes(x=jitter(Sepal.Width), y=jitter(Sepal.Length), col=Species)) +
geom_point() +
labs(x="Sepal Width (cm)", y="Sepal Length (cm)", col="Species", title="Iris Dataset") + theme_dark()
point_plot
bar_plot <- ggplot(iris, aes(x=Species, y=Sepal.Width, fill=Species)) +
geom_bar(stat="summary", fun.y="mean") +
labs(x="Species", y="Mean Sepal Width (cm)", fill="Species", title="Iris Dataset")
bar_plot 
box_plot <- ggplot(iris, aes(x=Species, y=Sepal.Width, fill=Species)) +
geom_boxplot() +
labs(x="Species", y="Sepal Width (cm)", fill="Species", title="Iris Dataset")
box_plot
image.png
library(ggthemr)
ggthemr("dust")
point_plot
bar_plot
boxplot


更多功能https://www.shanelynn.ie/themes-and-colours-for-r-ggplots-with-ggthemr/