I have a large dataset and would like to plot boxplots of two paired samples using ggpaired(). However, ggpaired() automatically adds connecting lines between the samples. Because I have lots of observations, this looks ridiculous and I would like to just get rid of the lines. I tried setting the line.size = 0 or line.color = "white" etc.
However, I am not able to plot the boxplots without the lines. Does anyone know how this can be fixed, or does anybody know a package that allows me to do so? Your help is appreciated!!
Sample code:
ggpaired(ToothGrowth, x = "supp", y = "len", color = "supp",
line.color = "gray", line.size = 0.4, palette = "jco")+
stat_compare_means(paired = TRUE)
Using the example given in the comments, if you wish to preserve everything else about the plot and not build the whole thing from scratch, the easiest thing to do is to remove the geom_line
layer:
Original
library(ggpubr)
p <- ggpaired(ToothGrowth, x = "supp", y = "len", color = "supp",
line.color = "gray", line.size = 0.4, palette = "jco") +
stat_compare_means(paired = TRUE)
p
Mofified
p$layers <- p$layers[-2]
p