从2018开始,小仙开始在公众号上分享R语言作图系列的文章,虽然是龟速更新,但到现在也是有了不少文章,常见的图表类型也画差不多了。可能R语言作图系列会有结束的一天,但小仙目前还是想继续写下去,目前小仙的思路是先把初级教程完善,尽量达到一号在手、美图我有的状态, 然后在此基础上提供一些图形拓展的思路, 拓展系列的教程不会那么详细,但会尽量保障大家在结合初级图形教程的基础上能够画出来。想告诉大家的是,虽然我们更新很慢,但是我们没有弃号,还在坚持啊啊啊!如果大家有什么图形想要画,但暂时有困难的,欢迎来信!
上次给大家分享了蜜蜂图的画法,这篇文章是在上次文章的基础上进行了一些拓展。蜜蜂图基本的作图语句可以看这里
https://mp.weixin.qq.com/s/XgtoTiz_aUNWmobvjPRSIQ
插播一句题外话,为了方便大家学习,小仙将R语言作图系列的数据共享到百度网盘链接里,在公众号里回复“数据”可收到链接以及提取码,欢迎大家使用。
本次用到的数据如下:
此数据可以通过在公众号里回复“R split beeswarm”获取
p1 <- ggplot(df, aes(x = variable, y = value, color = Class)) +
geom_beeswarm(priority = "descending") +
scale_color_manual(values = c("#AF0F11", "#3372A6")) +
theme(axis.line = element_line(colour = "black"),
panel.background = element_blank(),
axis.ticks = element_line(),
axis.text = element_text(color = "black")) +
labs(x = " " , y = "Gene expression")
p1
p2 <- ggplot(df, aes(x = variable, y = value, color = Class)) +
geom_beeswarm() +
scale_color_manual(values = c("#AF0F11", "#3372A6")) +
theme(axis.line = element_line(colour = "black"),
panel.background = element_blank(),
axis.ticks = element_line(),
axis.text = element_text(color = "black")) +
labs(x = " " , y = "Gene expression")
p2
p3 <- ggplot(df, aes(x = variable, y = value)) +
geom_violin(aes(fill = variable), width = 1.2, trim = FALSE) +
geom_beeswarm(color = "white") +
theme(axis.line = element_line(colour = "black"),
panel.background = element_blank(),
axis.ticks = element_line(),
axis.text = element_text(color = "black")) +
labs(x = " " , y = "Gene expression")
p3
p4 <- ggplot(df, aes(x = variable, y = value)) +
geom_split_violin(aes(fill = Class), width = 1.2, trim = FALSE) +
geom_beeswarm(color = "white") +
theme(axis.line = element_line(colour = "black"),
panel.background = element_blank(),
axis.ticks = element_line(),
axis.text = element_text(color = "black")) +
labs(x = " " , y = "Gene expression")
p4