首页 > 解决方案 > 如何删除 ggstatsplot 包中的点 ggwithinstats

问题描述

我使用网站上的示例,但我想删除这些点,以便只保留中位数的连接。

我的代码。

# for reproducibility
set.seed(123)
library(ggstatsplot)


df_disgust <- dplyr::filter(bugs_long, condition %in% c("LDHF", "HDHF"))

p2 <-
  ggstatsplot::ggwithinstats(
    data = df_disgust,
    x = condition,
    y = desire,
    xlab = "Condition",
    ylab = "Desire to kill bugs",
    type = "np",
    conf.level = 0.99,
    title = "Non-parametric Test",
    package = "ggsci",
    palette = "uniform_startrek",
    point.args = list(size = 0, alpha = 0.5),
    point.path = FALSE,
    centrality.plotting = TRUE,
    outlier.tagging = T,
    ggtheme = ggthemes::theme_map()
  )
ggstatsplot::combine_plots(
  plotlist = list(p2),
  plotgrid.args = list(nrow = 2),
  annotation.args = list(
    title = "Effect of disgust on desire to kill bugs ",
    caption = "Source: Bugs dataset from `jmv` R package"
  )
)

据我所知,负责点的参数point.args = list(size = 3, alpha = 0.5),但是当我设置size = 0点时不会消失。

我没有找到任何其他对分数负责的参数

标签: rplot

解决方案


FAQ-15:https ://indrajeetpatil.github.io/ggstatsplot/articles/web_only/faq.html#15-how-can-i-remove-a-particular-geom-layer-from-the-plot-

ggstatsplot不会直接允许您删除它们,但您可以使用一些解决方法:

library(ggstatsplot)
library(gginnards)


df_disgust <- dplyr::filter(bugs_long, condition %in% c("LDHF", "HDHF"))

p <- ggwithinstats(df_disgust, condition, desire, type = "np", point.path = FALSE)

delete_layers(p, "GeomPoint")

reprex 包(v2.0.0)于 2021-06-14 创建


推荐阅读