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

legends offsets histograms #23

Closed gatcbiotech closed 8 years ago

gatcbiotech commented 8 years ago

Hi, when you have legends, the marginal plots are not displayed correctly to the axis. See the attached files for an example. Regards, Yadhu

without legend withlegend

daattali commented 8 years ago

Thanks for the report. Please provide some code for a minimal reproducible example if you could. I'll take a look in a couple weeks after I finish my thesis and defense

gatcbiotech commented 8 years ago

myplot <- ggplot(mtcars, aes(wt, mpg)) + geom_point(aes(color=vs)) ggExtra::ggMarginal( p = myplot, type = 'histogram', margins = 'both', size = 5, col = 'black', fill = 'gray' )

daattali commented 8 years ago

I just tried looking into this a little bit, and I'm not sure how to fix this. I'm not sure how to tell if a ggplot object has a legend or not, if anyone knows a way to figure that out, or has another fix for this issue, I'll welcome any ideas

crew102 commented 8 years ago

I can take a shot at this over the weekend. Pretty sure I know how to fix.

daattali commented 8 years ago

@crew102 that'd be great

daattali commented 8 years ago

Fixed thanks to @crew102