r - 如何在R ggboxplot中按组生成上下误差线?
问题描述
我正在尝试使用 R 创建带有“星”符号的分组箱线图ggboxplot
。但是,我在添加误差线时遇到了困难,尤其是上下水平线。这是我的代码和输出。
library(ggpubr)
library("ggsignif")
s=15
p <- ggboxplot(data, x = "MRI", y = "featurevalue",
color = "black",fill="filename",palette = "aaas",
notch = TRUE,outline=FALSE,
font.x = s,font.y = s,
font.xtickslab = s,font.ytickslab = s,
font.legend = s,
legend.title="",
ylim = c(0, 1.04))
p +
stat_compare_means(size=8,aes(group = filename),label = "p.signif",hide.ns = TRUE,method = "t.test") +
theme(panel.border=element_rect(fill='transparent',color='black')) +
theme(legend.background=element_rect(fill="transparent",colour="black"),
legend.position=c(0.85,0.93),
legend.title = element_blank(),
legend.margin=margin(c(0.1,0.1,0.1,0.1), unit='cm'),
legend.key = element_blank(),
plot.margin=unit(c(0.2,0.2,0.1,0.1),'lines'))
有人说使用ggplot2
会自动出现错误栏。但我不能用ggplot2
. 我曾尝试使用error.plot = c("upper_errorbar", "lower_errorbar")
inggboxplot
来添加错误栏,但此命令似乎不适用于分组箱线图,我在下面显示了我得到的图。有没有正确的方法来组合这个推荐和add.params = list(group=)
,以生成分组误差条?
任何人都可以帮助在分组箱线图中生成误差线吗?谢谢你的帮助!
解决方案
您是否尝试过 ggboxplot() 函数中的“错误栏”参数?
bxp.errorbar = TRUE
在 ggboxplot() 函数中给出上述参数并检查。
推荐阅读
- java - POI 并将单元格设置为 VerticalAlignment.MIDDLE
- mvvm - Xamarin Forms Prism 通过 CommandParameter 传递属性
- javascript - 需要将 recaptcha 添加到 Bootstrap Validator 联系表单
- javascript - 无法访问对象属性的值
- azure - ARM 模板是否提供了一种在创建资源期间捕获日志的方法
- php - 通过表单提交阿拉伯语内容导致禁止页面
- google-chrome - Google Chrome Lighthouse/Audit 减少 JavaScript 执行时间 - 什么是“其他”
- sql - 在没有交付行的情况下填充 0 值
- json - 如何在 .net core 3.0 中反序列化 json
- javascript - 在数据中创建假 $route