erocoar / ggpol

🌍 Parliament diagrams and more for ggplot2
https://erocoar.github.io/ggpol/
Other
104 stars 10 forks source link

Feature request, plot full box with dots #9

Open wavefancy opened 4 years ago

wavefancy commented 4 years ago

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

erocoar commented 3 years ago

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