-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Histograms axes limits are wrong when using geom_smooth() #9
Comments
Thanks for the report. Fixing |
A version of this problem appears to still exist when geom_smooth() extends the axis range.
|
Thanks for the report. I'm really busy for the next 2 months, I'll try to take a look when I can, but unfortunately this is low priority at the moment |
@WilDoane I looked into this a bit but wasn't able to find a good solution. What I tried to do is to just copy the scale aesthestics from the main plot to the marginal plot, but for some reason it doesn't work. If anyone wants to tackle this, I'd gladly welcome a PR. |
@daattali "What I tried to do is to just copy the scale aesthestics from the main plot" -> where exactly in ggMarginal? Do you mean ggplot2::scale_x_continuous(breaks = mean(getLimits(pbTop, "x")),
labels = ylabel) ? I'm looking at the problem because a colleague of mine uses custom x and y limits. |
@masalmon getLimits() and getScale() are two functions I use to try to match the original plot. If your colleague uses custom x and y limits, she should be fine, that works. Example:
What doesn't work is using |
The original issue raised by zakahmad in 2015 still seems to be present, without using geom_smooth. If the default axis limits are over-ridden, the x-axis marginal plot aligns correctly with the data, but the y-axis marginal plot does not. Here is some code to illustrate the situation [R 3.4.3; ggExtra_0.7; ggplot2_2.2.1]: df <- data.frame(x = rnorm(500, 50, 10), y = runif(500, 0, 50)) |
@jimoeppen , the problem with using limits with ggMarginal that you mention is related to #81. |
Thank you for the rapid response, and for all the work that goes into ggExtra.
I think #81 implies that setting limits on x affects the y marginal, and vice-versa. As far as I have seen, the x marginal responds correctly to the x limits. It is only the y marginal that does not reflect user-specified y axis limits.
Best wishes
Jim Oeppen
Associate Professor
Biodemography Unit
Department of Public Health
University of Southern Denmark (SDU)
J.B. Winsløws Vej 9B
DK-5000 Odense C
Office Phone: +45 6550 9360
From: Chris Baker [mailto:[email protected]]
Sent: 11 January 2018 16:39
To: daattali/ggExtra <[email protected]>
Cc: Jim Oeppen <[email protected]>; Mention <[email protected]>
Subject: Re: [daattali/ggExtra] Histograms axes limits are wrong when using geom_smooth() (#9)
@jimoeppen<https://github.com/jimoeppen> , the problem with using limits with ggMarginal that you mention is related to #81<#81>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#9 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AHsb6IHW57spF4DPz_nRSeeF-sYDRX5Jks5tJisbgaJpZM4EdDzn>.
|
Hi @jimoeppen, both axis are actually problematic. You can see both graphs in #81 for this, or just check out the below code, in which the x marginal plot is wrong and we don't even get a y marginal plot. library(ggplot2)
library(ggExtra)
p <- ggplot(data = mtcars) +
geom_point(aes(wt, mpg)) +
ylim(c(25, 35))
ggMarginal(p, type = "histogram") The bigger issue mentioned in #81 is that ggMarginal is not using the correct range for the marginal plots. |
I just encountered this same issue -- ggMariginal histograms are not lining up with the y-axis correctly after adjusting the limits. Is there any update on a solution? |
A huge feature was just added, the fix for this is next |
fixed |
Occasionally, I like to have both axes of a scatter have the same range or limits (in the original plot below I set the limits to c(-20,30)). However, to demonstrate the issue, I changed the y-axis limits using scale_y_continuous(limits = c(-40,30)) while having scale_x_continuous(limits = c(-20,30)).
The actual range of the data in the x-axis is: -17.49, 28.56 and on the y-axis is: -9.63, 17.58
I think the location of histograms should adjust and shift when the axes limits are shifted.
The text was updated successfully, but these errors were encountered: