【发布时间】:2021-07-28 09:42:12
【问题描述】:
我对 R 非常陌生,并试图为我的数据创建一个小提琴图网格。我能够得到我想要的网格布局,但是,当我制作网格时,我的图在 x 轴上,如果它们都被绘制在一起的话。
p2 <- ggplot(data, aes(x=Treatment, y=ECM, fill=Treatment)) +
geom_violin(trim=FALSE) + facet_grid (Time ~ Duff) +
labs(title=" ",x=" ", y = "ECM Root Colonization (%)")
p2 + theme_classic() + theme(legend.position="right") + stat_summary(fun=mean, geom="point", size=2, color="black") + theme(axis.title.x=element_blank(), axis.text.x=element_blank(),axis.ticks.x=element_blank()) + scale_fill_discrete(name = "Treatment", labels = c("B-M- B/B", "B-M- B/M (B)", "B-M- B/M (M)", "B-M- M/M", "B-M+ B/B", "B-M+ B/M (B)", "B-M+ B/M (M)", "B-M+ M/M", "B+M- B/B", "B+M- B/M (B)", "B+M- B/M (M)", "B+M- M/M", "B+M+ B/B", "B+M+ B/M (B)","B+M+ B/M (M)", "B+M+ M/M")) +
theme(strip.background = element_rect(colour="black", fill="white",
size=1.5, linetype="solid")) +
theme(strip.text.x = element_text(size=15, color="black",
face="bold"))
因为 x 轴是“治疗”,这也是我的填充,我尝试使用以下代码释放比例,但这并没有改变绘图。
+ facet_grid (Time ~ Duff, scales="free")
+ facet_grid (Time ~ Duff, scales="free_x")
我也尝试使用 facet_wrap 重新创建它,但没有成功。
我很乐意提供任何其他可能有用的信息。提前感谢您的任何建议!
【问题讨论】:
-
欢迎来到 SO!为了让其他人更容易地帮助您,创建一个最小的可重现示例会很棒! stackoverflow.com/questions/5963269/…
标签: r ggplot2 facet-grid violin-plot