【简说基因】ggplot2 是一种面向数据的绘图系统,可以先进行数据相关的绘图以探索数据,最后呈现结果时,再通过主题控制所有非数据元素。
hrbrthemes 是一个专注于为 ggplot2 提供以排版为中心的主题和主题组件的扩展包。
核心主题:theme_ipsum(“ipsum”在拉丁语中是“精确”的意思)使用 Arial Narrow 字体,这个字体在几乎所有现代系统上都应该安装了,所以它是“免费”的(没有版权问题)。这种字体比较紧凑,具有固定的默认字距配对和几何数字。
安装
install.packages("hrbrthemes") # NOTE: CRAN version is 0.8.0
# or
remotes::install_github("hrbrmstr/hrbrthemes")
主题
theme_ipsum
library(ggplot2)
library(hrbrthemes)
library(showtext)
# 对于没有的字体,自行下载字体文件后通过 showtext 包加载进R环境。
showtext_auto()
p = ggplot(mpg, aes(class, fill = drv)) +
geom_bar(width = 0.7) +
theme(legend.position = "top")
p + theme_ipsum()

theme_ft_rc
p + theme_ft_rc()

scale_fill_ipsum
p + scale_fill_ipsum() + theme_ipsum()

scale_fill_ft
p + scale_fill_ft() + theme_ft_rc()

网格线
X 轴方向
p + scale_fill_ipsum() + theme_ipsum(grid = 'X')

Y 轴方向
p + scale_fill_ipsum() + theme_ipsum(grid = 'Y')

更多用法请参考 hrbrthemes 官方网站:
https://hrbrmstr.github.io/hrbrthemes/
专栏文章:
ggplot2 主题专栏 02:时尚又商业范儿十足的 ggthemr 扩展包
ggplot2 主题专栏 01:内置主题和 ggthemes 扩展包
——————END——————
关注公众号:简说基因,阅读更多生信好文。
如果你有数据分析需求,欢迎与我们合作: