堆叠条形图,每列内的间距(ggplot2)

问题描述 投票:0回答:1

我已经弄清楚如何用我的数据制作堆积条形图,但现在该图使得每种结构类型的结构数量看起来都是相同的。我认为这是不准确的,并且不确定为什么 R 在总结构的每一列中显示相同的填充水平。构成“总计”的不同类型的结构以不同的数量出现在数据中,所以我不确定为什么这张图使它们看起来均匀。

这是我当前的代码:

ggplot(Brass.ready, aes(x=Genus, y=Total))+
geom_col(aes(x=Genus, y=Total, fill=Type)) + 
theme(axis.text.x = element_text(angle = 65, vjust = 0.75)) + 
labs(title="Mycorrhizal Structures Across Genera", x ="Genus", y = "Total Fungal Structures")

ggplot2 bar-chart fill stacked-bar-chart
1个回答
0
投票

没有数据我无法确定,但看起来您还没有对数据进行分组 尝试:

ggplot(Brass.ready, aes(x=Genus, y=Total, group=Type))+
geom_col(aes(x=Genus, y=Total, fill=Type)) + 
theme(axis.text.x = element_text(angle = 65, vjust = 0.75)) + 
labs(title="Mycorrhizal Structures Across Genera", x ="Genus", y = "Total Fungal Structures")
© www.soinside.com 2019 - 2024. All rights reserved.