Closed crew102 closed 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:
->
assignments to <-
(to match the coding style of the rest of the code)exists("lgnd_grob")
and instead do something like initialize lgnd_grob to NULL and check if its not NULL, because right now if the variable exists on the user's global env it will cause problems (that shouldn't really happen, it'd be a huge coincidence, but it just feels safer not to use exists()
)if (utils::packageVersion("ggplot2") >= "2.0.0")
if you don't think this'll work for older versionsThe 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?
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?
@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 :)
Yeah, I agree regarding placement of legend. I'll work on the fix this weekend and issue another PR.
Thank you in advance
Still working on this...It's tougher than it looks. Hopefully I'll have something by this weekend.
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
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.
Of course, I probably should have done that before
legend.position = "none"
is the syntax used in old versions of ggplot2. Do you happen to know off hand? If it isn't, then then the fix may not work for some users.