-
Notifications
You must be signed in to change notification settings - Fork 2.1k
geom_abline 3.3.4 odd y limits #4514
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
Comments
Could you please provide a reproducible example that depends on nothing but base R and ggplot2? And please simplify the example so all extraneous information is removed. This will make it easier to reason about the issue. Also, if you can, please use |
Sorry for the bother, @clauswilke Here is a very simpler example. Is this new default y limit intended ? Should we adapt our code ? Thanks a lot for your work. Arnaud
|
Looks like library(ggplot2)
library(patchwork)
df <- data.frame(
x = c(10000, 10001, 10002),
y = c(500, 502, 501)
)
p <- ggplot(df) +
geom_abline(
intercept = -9500,
slope = 1
) +
geom_point(aes(x, y))
p | p + xlim(0, 10010) Created on 2021-06-16 by the reprex package (v1.0.0) |
Is it related to this? where the range of the line was extended to fix another issue: |
after having tried with and without, it is actually linked to that commit 041e287 Seems like the intercept being told that way as a known aesthetic for y, it behaves as @clauswilke told |
Yes, in hindsight, this was a problematic change. We want the intercept to get transformed but we don't want it to enter the limit calculations. We may need to separate out those two functions, or let the geoms/stats declare which aesthetics should be used for each of these calculations. The latter approach might be cleaner but is more work. |
I'm leaning on actually rolling this change back and doing a quick patch release.. thoughts, @clauswilke and @yutannihilation ? |
I agree. The newly introduced bug is more problematic than the bug that was fixed, in my opinion. |
I am also having trouble with geom_abline 3.3.4, noticed this issue and think it could be related? |
Agreed on the ggsave issues — was planning on including that as well. Will work on this today |
Hi, Just to confirm that, as for me, ggplot2 3.3.5 solved the issue. |
The fix for 3.3.5 only partly fixes the issue for me (at least, I believe that the issue below is the same as the initially-reported issue here). Specifically, when adding one log10 scale, the abline disappears now, but adding both puts it back: library(ggplot2)
p <-
ggplot(data.frame(x=1, y=1), aes(x=x, y=y)) +
geom_point() +
geom_abline(slope=1, intercept=0)
# basic plot shows up as expected
p # adding scale_x_log10() drops the line which is not expected
p + scale_x_log10() # adding scale_y_log10() drops the line which is not expected
p + scale_y_log10() # adding both log10 scales puts the line back as desired
p + scale_x_log10() + scale_y_log10() Created on 2021-07-14 by the reprex package (v2.0.0) |
@billdenney I think this is the original issue we tried to solve in 3.3.4 but reverted in 3.3.5 we still need to figure out a fix for that |
Hi,
I am aware of #4024 and #3741 that modify geom_abline. Through, the abline modification in 3.3.4 has had some strange results for the default y limits, maintening my modest package disaggR and in particular its autoplot method for in_scatter. I can't decide if it's a feature or a bug, I'm sorry if I make a mistake to report that.
On 3.3.4 The default y limits seems to be very odd to me

on 3.3.3 the behavior was as expected

The text was updated successfully, but these errors were encountered: