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

Legend fix #25

Closed crew102 closed 8 years ago

crew102 commented 8 years ago
daattali commented 8 years ago

Thank you, I had no idea how to do this! I really appreciate the help. I have a few comments about the code:

The last comment is not about the code: I see you chose to move the legend to the bottom even though by default plots will have the legend on the right. I understand that choice, because this way the marginal plots are right beside the plot, but I feel like that's not the correct thing to do. If I pass in a plot object to ggMarginal , I expect to get back the exact same plot as the main plot, without having its legend position changed. Do you think you could respect the legend location?

crew102 commented 8 years ago

Ah, I think I didn't understand the issue correctly. Just to clarify, the desired behavior is for the section of the x-axis marginal plot which I have circled in orange below to be moved over to the left, so that it stays in line with the x range of the scatter plot? rplot

daattali commented 8 years ago

@crew102 Yes, I think that would be more user friendly behaviour. Do you agree? That way the original plot doesn't get changed, and the marginal plots are in-line with the main plot. Figuring out the legend was half the work, keeping them exactly inline is the next half :)

crew102 commented 8 years ago

Yeah, I agree regarding placement of legend. I'll work on the fix this weekend and issue another PR.

daattali commented 8 years ago

Thank you in advance

crew102 commented 8 years ago

Still working on this...It's tougher than it looks. Hopefully I'll have something by this weekend.

daattali commented 8 years ago

Yeah I know it's not that simple :) Any time. I won't get to take a look for a few days, I have too many things going on this week

crew102 commented 8 years ago

Finally figured this out...Do you mind if I pull the functions you define inside of ggMarginal out of the main body (e.g., getScale, getLimits, etc.) before I submit a new PR? It's easier for me to navigate through ggMarginal if those functions are moved outside.

daattali commented 8 years ago

Of course, I probably should have done that before