写毕业论文的时候老板提到要用一张图表示分类系统的变化,于是像到用桑基图来呈现这个变化的过程,具体操作步骤如下(越来越不喜欢写注释了,大家将就着看):
输入表格如图:
rm(list=ls())
setwd("D:\\List of Incertae sedis\\毕业论文")
library(ggalluvial)
library(ggplot2)
library(dplyr)
agar_taxa<-read.csv("表 蘑菇目不同分类系统对比.csv")
# 指定顺序
author_order <- c("Dentinger et al. 2016", "Vizzini et al. 2024", "This study")
# 然后将 Author列转换为因子,并指定顺序
agar_taxa$Author <- factor(agar_taxa$Author,levels = author_order)
# 画图
p <- ggplot(agar_taxa,
aes(x = Author, stratum = Suborder, alluvium = Family,
y = Freq,
fill = Suborder, label = Suborder)) +
scale_x_discrete(expand = c(.1, .1)) +
geom_flow() +
geom_stratum(alpha = .5) +
geom_text(stat = "stratum", size = 3) +
theme(legend.position = "none",
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x = element_text(size=12))
ggsave("plot.png",plot = p,width=10,height=8,dpi=300)