ggpol icon indicating copy to clipboard operation
ggpol copied to clipboard

Feature request, plot full box with dots

Open wavefancy opened this issue 5 years ago • 1 comments

Hi Developers.

Is there any chance to support box with dots as full box plot, instead of just half box. An example of style as below, a plot from poltly.

boxplot with dots side by side

Thank you very much for this great work.

Best regards Wallace

wavefancy avatar Jul 20 '20 20:07 wavefancy

Hi, sorry for my late reply. I hope this is still useful somehow :) It might be easiest for you to use the gghalves package and plot a half boxplot (with center = TRUE and a half point plot.

E.g.:

library(gghalves)
df <- data.frame(score = rgamma(150, 4, 1), 
                 gender = sample(c("M", "F"), 150, replace = TRUE), 
                 genotype = factor(sample(1:3, 150, replace = TRUE)))

ggplot(df) + 
  geom_half_boxplot(aes(x = genotype, y = score, fill = gender), center = TRUE, side = "r") +
  geom_half_point(aes(x = genotype, y = score, fill = gender), side = "l", shape = 21) +
  scale_fill_manual(values = c("#ecb21e", "#812e91")) 

image

erocoar avatar Mar 06 '21 12:03 erocoar