【简说基因】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)

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)

主题 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)

主题 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)

——————END——————
关注公众号:简说基因,阅读更多生信好文。
如果你有数据分析需求,欢迎与我们合作: