187-想用ggplot画出base包的效果

刘小泽写于2020.5.18 这个需求是因为现实发表的图片许多都不需要太多的粉饰,简洁明了即可 但是基础包的作图又不太友好,所以怎么把ggplot2的便利与base的简洁结合起来呢?

上例子

library(ggplot2)
# 一个经典的散点图,并且带分组
p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
                                     colour = factor(gear))) + facet_wrap(~am)

先看一下这个图

image-20200518093613313

效果还行,就是看着不太简洁,ggplot2有自带简洁的模板,看看效果

p+theme_classic()

image-20200518093712212

好了一点,再试试ggthemes

library(ggthemes)
p + theme_base(base_size = 10, base_family = "Times New Roman")

image-20200518094115953

这个输出结果还是ggplot类型的对象,因此可以输出为ppt再进行后续编辑,可以看:

再也不用费力调整GO富集分析的输出图片了

Yunze Liu
Yunze Liu
Bioinformatics Sharer

Co-founder of Bioinfoplanet(生信星球)

Next
Previous

Related