【发布时间】:2020-07-01 11:34:05
【问题描述】:
我想在箱线图中展示两组随时间推移的发展情况,并为每个组添加重要标签(组内比较)。我有一个使用 ggpubr::stat_compare_means 的工作示例,但我无法正确定位这两个几何图形。
我尝试了position = position_dodge(width=0.5) 和其他几个位置元素,但由于某些原因,它们根本不会移动。我想要的输出将使每个标签集水平移动以覆盖每个组框,并垂直调整为不重叠。
使用diamonds的示例代码:
df <- filter(diamonds, color == "J" | color == "E")
ggplot(data = df, aes(x = cut, y = price, fill = color)) +
geom_boxplot() +
stat_compare_means(method = "t.test",data = filter(df, color == "J"), comparisons = list(c("Fair","Good"),c("Fair","Very Good"),c("Fair","Premium"))) +
stat_compare_means(method = "t.test",data = filter(df, color == "E"), comparisons = list(c("Fair","Good"),c("Fair","Very Good"),c("Fair","Premium")))
【问题讨论】:
-
也许这可以作为一个很好的激励来摆脱在情节中具有多个显着性条的多个组间和组内测试?可视化不一定会受益于显着性栏的人口过多...如果您真的想呈现这么多显着性值,我认为使用表格会更好。
-
虽然这可能是真的,但我仍然需要生成所需的图形。只有两组标签,用于参考组的 x 轴上的组间比较。