首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ggthemr|为ggplot图形添加主题和颜色

ggthemr|为ggplot图形添加主题和颜色

作者头像
生信编程日常
发布2020-06-16 19:03:20
9690
发布2020-06-16 19:03:20
举报

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/

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档