Warm tip: This article is reproduced from stackoverflow.com, please click
boxplot ggpubr r

How to change the order of boxplots in ggboxplot?

发布于 2021-01-30 13:20:39

Below is the code I currently have which creates the below graph. I'm instead trying to make a graph where the blue boxplots (pun) are next to each other under the title of 'pun' in the x axis, next to the yellow boxplots 'mv'.

ggboxplot(
  d, x = "Condition.Name", y = c("pun", "mv"), 
  merge = TRUE, palette = "jco",
  title = NULL,
  xlab = '',
  ylab = ''
  )

Graph

Questioner
samf94
Viewed
0
Chuck P 2020-10-09 23:59

Using mtcars because you didn't provide data. You need to combine not merge with ggpubr::ggboxplot

library(ggpubr)
#> Loading required package: ggplot2
ggboxplot(
   mtcars, 
   x = "am", 
   y = c("disp", "hp"),
   combine = TRUE,
   color = c("#0073C2FF", "#EFC000FF", "#0073C2FF", "#EFC000FF"),
   title = NULL,
   ylab = ''
)