繁体   English   中英

如何使用 boxplot R 命令在 boxplot 上添加 p 值?

[英]How to add p-value on boxplot using boxplot R command?

我使用 R 中的 boxplot 函数来制作箱线图。 我想在我的箱线图中添加 p 值。 我该怎么办? 有使用ggplot的方法,但我不想使用ggplot2。 我的代码是:

boxplot(wbc~Vital_status,
        data=final_df$ximp,
        main="boxplots of wbc ",
        xlab="Vital status",
        ylab="wbc",
        col="orange",
        border="brown",
        outline=FALSE,boxwex=.5, xaxt='n', frame=FALSE
)
axis(side = 1,at = 0:3,labels=c("", "alive", "dead", ""),lwd.ticks = FALSE)

在此处输入图片说明

使用mtexttext

由于您没有提供final_df ,我只使用了其中一个示例

boxplot(len ~ dose:supp, data = ToothGrowth,
        boxwex = 0.5, col = c("orange", "yellow"),
        main = "Guinea Pigs' Tooth Growth",
        xlab = "Vitamin C dose mg", ylab = "tooth length",
        sep = ":", lex.order = TRUE, ylim = c(0, 35), yaxs = "i")
mtext("p=0.05", side=3)
text(x=3,y=30,labels="p=0.05")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM