我有一个带有分类变量的数据框,我将其命名为Treatment。它具有以下级别:初始,nl + amb,cl + amb,nl + ambup和cl + ambup。响应变量具有不同的阶段,因此我绘制了堆叠的条形图(每个阶段都是分数)。我完成了三个采样(2017年9月至2018年2月)。
当我在ggplot中绘制数据时,我希望级别“ Initial”仅在9月出现,但要一直重复到2月,其余级别也是如此。
有人对如何解决这个问题有想法吗?
谢谢!! [我只希望9月的“初始”,其他月份的其他水平也一样] [1]
这就是我为剧情写的东西
areafraction <- ggplot(short, aes(x = treatment, y = areafraction, fill = factor(short$stage, levels = c("at","matd","mat","ty","sy","py","od", "ca","pn"))))+
geom_bar(stat = "identity", position = "fill")+
theme_bw()+
scale_fill_manual(values = c("honeydew4","darkorange1","dodgerblue4","darkorchid4","goldenrod4","darkslategrey","hotpink4","lightslateblue","royalblue4"))+
facet_wrap(~factor(short$date, levels = c("september 2017", "januar 2018", "februar 2018")))+
theme(legend.title = element_blank())