You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ggstatsplot使用技巧:如何删除ggwithinstats中连接均值的线条

ggwithinstats删除均值连接红线的方法

你只需要在ggwithinstats函数的调用参数中添加centrality.path = FALSE即可关闭连接各组均值的红色粗线条,该参数默认值为TRUE,专门用于控制是否展示组内均值的连接路径。

修改后的完整代码如下:

ggstatsplot::ggwithinstats(
  data = WRS2::WineTasting,
  x = Wine,
  y = Taste, 
  pairwise.comparisons = TRUE, 
  pairwise.display = "s", 
  pairwise.annotation = "p", 
  title = "Wine tasting", 
  caption = "Data from: `WRS2` R package", 
  ggtheme = ggthemes::theme_fivethirtyeight(), 
  ggstatsplot.layer = FALSE,   
  messages = FALSE,
  centrality.path = FALSE # 关闭均值连接红线
)

如果你后续需要调整这条连线的样式而非完全删除,可以通过centrality.path.args参数自定义样式,示例配置如下:
centrality.path.args = list(color = "blue", size = 1, linetype = "dashed")

内容的提问来源于stack exchange,提问作者mattaf30

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 17:06:03