Home > Enterprise >  How to create boxplot graph and same coloured spots around them
How to create boxplot graph and same coloured spots around them

Time:01-07

I have a question about this kind of graph.

I do not know whether there is someone that can suggest some tutorials/websites pages/question on Stack Overflow can show how it would be possible to create this kind of graph and specifically, I'm interested on how to obtain/show the spots around the same coloured box.

Thanks in advance

enter image description here

CodePudding user response:

Here is an example using the ggpubr package and the mtcars dataset:

library(ggpubr)

compare_means(disp ~ cyl, data = mtcars,  method = "t.test")
my_comparisons <- list( c("4", "6"), c("6", "8"), c("4", "8") )

ggboxplot(mtcars, x = "cyl", y = "disp", color = "cyl", add = "jitter")  
  stat_compare_means(comparisons = my_comparisons) 
  stat_compare_means(label.y = 700) 

enter image description here

  •  Tags:  
  • Related