ggplot2主题专栏01:内置主题和ggthemes扩展包

【简说基因】ggplot2 是一种面向数据的绘图系统,可以先进行数据相关的绘图以探索数据,最后呈现结果时,再通过主题控制所有非数据元素。

ggplot2 有 8 个内置主题和许多扩展主题包,本系列文章将会对 ggplot2 目前可用的主题进行全面汇总,方便自己和读者朋友们查阅。

内置主题:8 个

library(ggplot2)
library(patchwork)

p = ggplot(mtcars) +
  geom_point(aes(wt, mpg, color = factor(cyl)))

p1 = p + theme_grey() + ggtitle("theme_grey()")
p2 = p + theme_bw() + ggtitle("theme_bw()")
p3 = p + theme_linedraw() + ggtitle("theme_linedraw()")
p4 = p + theme_light() + ggtitle("theme_light()")
p5 = p + theme_dark() + ggtitle("theme_dark()")
p6 = p + theme_minimal() + ggtitle("theme_minimal()")
p7 = p + theme_classic() + ggtitle("theme_classic()")
p8 = p + theme_void() + ggtitle("theme_void()")

p1 + p2 + p3 + p4 +
  p5 + p6 + p7 + p8 + plot_layout(ncol = 2)
d69a4bec6697fe99f0225ce83f0672a7.png

ggthemes 主题:22 个

主题 1-8

# install.packages('ggthemes', dependencies = TRUE)
library(ggthemes)

p1 = p + theme_base() + ggtitle("theme_base()")
p2 = p + theme_calc() + ggtitle("theme_calc()")
p3 = p + theme_clean() + ggtitle("theme_clean")
p4 = p + theme_economist() + ggtitle("theme_economist()")
p5 = p + theme_economist_white() + ggtitle("theme_economist_white")
p6 = p + theme_excel() + ggtitle("theme_excel()")
p7 = p + theme_excel_new() + ggtitle("theme_excel_new()")
p8 = p + theme_few() + ggtitle("theme_few()")

p1 + p2 + p3 + p4 +
  p5 + p6 + p7 + p8 +
  plot_layout(ncol = 2)
a12756899d0b825ac817180dbc82bb5b.png

主题 9-16

p1 = p + theme_fivethirtyeight() + ggtitle("theme_fivethirtyeight()")
p2 = p + theme_foundation() + ggtitle("theme_foundation()")
p3 = p + theme_gdocs() + ggtitle("theme_gdocs")
p4 = p + theme_hc() + ggtitle("theme_hc()")
p5 = p + theme_igray() + ggtitle("theme_igray")
p6 = p + theme_map() + ggtitle("theme_map()")
p7 = p + theme_pander() + ggtitle("theme_pander()")
p8 = p + theme_par() + ggtitle("theme_par()")

p1 + p2 + p3 + p4 +
  p5 + p6 + p7 + p8 +
  plot_layout(ncol = 2)
7437efca285d450164e334a2eed8b034.png

主题 17-22

p1 = p + theme_solarized() + ggtitle("theme_solarized()")
p2 = p + theme_solarized_2() + ggtitle("theme_solarized_2()")
p3 = p + theme_solid() + ggtitle("theme_solid")
p4 = p + theme_stata() + ggtitle("theme_stata()")
p5 = p + theme_tufte() + ggtitle("theme_tufte")
p6 = p + theme_wsj() + ggtitle("theme_wsj")


p1 + p2 + p3 + p4 + p5 + p6 +
  plot_layout(ncol = 2)
a0d78703a093c38c7f7fe116377bcaf8.png

——————END——————

关注公众号:简说基因,阅读更多生信好文。

如果你有数据分析需求,欢迎与我们合作:

4c83bcaac6f54f3445b01fe45e96da4b.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值