daattali / ggExtra

📊 Add marginal histograms to ggplot2, and more ggplot2 enhancements
http://daattali.com/shiny/ggExtra-ggMarginal-demo/
Other
383 stars 45 forks source link

ggMarginal grouped boxplots are different widths #169

Closed nathanieldelaneybusch closed 1 year ago

nathanieldelaneybusch commented 2 years ago

Marginal boxplots colored by groups produce boxes of different widths. Using params lists (e.g. xparams = list(varwidth = FALSE)) does not appear to fix the issue.

Example:

scatterplotMPG = ggplot( data=mpg, aes(x=cty, y = hwy)) +
  geom_point(data=mpg[mpg$drv%in%c('r', 'f'), ], aes(color=factor(drv)), alpha=0.5) +
  geom_point(data=mpg[mpg$drv%in%c('4'), ], color='gray', alpha=0.3)+
  theme(legend.position = "bottom")

ggExtra::ggMarginal(scatterplotMPG, type = "boxplot",
                    groupFill = TRUE, groupColour = TRUE, size=7,
                    xparams = list(varwidth = FALSE),
                    yparams = list(varwidth = FALSE))

image

I am using ggExtra 0.10.0 and ggplot2 3.3.5 on a windows machine.

crew102 commented 1 year ago

Hey @nathanieldelaneybusch , sorry for the delay, and thanks for the reproducible example. I'll open up a PR soon with a fix.

daattali commented 1 year ago

fixed with #173 -- thanks to @crew102