[英]R geom_signif cannot plot the significance bar for no apparent reason, seems related to x scale setting
我希望将 geom_signif 用于 plot 我的数据的显着性条,其中包含三个处理级别,test_df 在这里:
治疗 | 回复 |
---|---|
0.1 | 0.002339829 |
0.1 | 0.002542650 |
0.1 | 0.001883246 |
0.15 | 0.002297212 |
0.15 | 0.001722406 |
0.15 | 0.002140492 |
0.15 | 0.001884400 |
0.2 | 0.001606958 |
0.2 | 0.002678250 |
0.2 | 0.001953940 |
0.2 | 0.002167357 |
这是我使用的代码:
test_df$treatment <- as.factor(test_df$treatment)
ggplot(data= test_df, aes(x=treatment, y=response)) +
geom_boxplot()+
geom_signif(comparisons = list(c("0.1", "0.15")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.15", "0.2")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.1", "0.2")), y_position = 0.0041, map_signif_level=TRUE)+
scale_x_discrete(limits = c("0","0.05","0.1","0.15","0.2"))+
ylim(0, 0.005)
但是,“0.15”、“0.2”之间的意义栏无法显示。 附上 plot: x 刻度设置为“0”、“0.05”、“0.1”、“0.15”、“0.2”
当我尝试在没有自定义 x 刻度的情况下使用 plot 时,最后一个意义栏可以毫无问题地显示。
ggplot(data= test_df, aes(x=treatment, y=response)) +
geom_boxplot()+
geom_signif(comparisons = list(c("0.1", "0.15")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.15", "0.2")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.1", "0.2")), y_position = 0.0041, map_signif_level=TRUE)+
ylim(0, 0.005)
附有 plot:无自定义 x 比例设置
对于我的第三次尝试,我尝试使用更宽的 x 比例范围 plot:
ggplot(data= test_df, aes(x=treatment, y=response)) +
geom_boxplot()+
geom_signif(comparisons = list(c("0.1", "0.15")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.15", "0.2")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.1", "0.2")), y_position = 0.0041, map_signif_level=TRUE)+
scale_x_discrete(limits = c("0","0.05","0.1","0.15","0.2", "0.25"))+
ylim(0, 0.005)
并且“0.15”、“0.2”之间的意义栏无法显示。 附上 plot: x 刻度设置为“0”、“0.05”、“0.1”、“0.15”、“0.2”、“0.25”
当我进一步调整 x 比例时:
ggplot(data= test_df, aes(x=treatment, y=response)) +
geom_boxplot()+
geom_signif(comparisons = list(c("0.1", "0.15")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.15", "0.2")), map_signif_level=TRUE)+
geom_signif(comparisons = list(c("0.1", "0.2")), y_position = 0.0041, map_signif_level=TRUE)+
scale_x_discrete(limits = c("0.05","0.1","0.15","0.2", "0.25"))+
ylim(0, 0.005)
现在显示“0.15”、“0.2”之间的重要性栏。 附上 plot: x 刻度设置为“0.05”、“0.1”、“0.15”、“0.2”、“0.25”
有谁知道为什么会这样? 我真的更希望将数据绘制在“0”、“0.05”、“0.1”、“0.15”、“0.2”的 x 刻度上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.