-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Consolidate scale definition of position aesthetics #5640
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
Conversation
Are there any plans to put the solution regarding this issue into the next release? It's really annoying that vertical lines plotted far outside the date limits are not considered. |
I totally agree with you there. We want the next release to be a low-risk hotfix where we mostly fix mistakes from 3.5.0 and not put in something disruptive. |
yes, this will be postponed |
After a lot of digging I found that the addition of |
Bunch of revue-check failures. I'm pretty sure that most or all are unrelated to this but please sift through them |
Merge branch 'main' into define_position_aes # Conflicts: # R/scale-discrete-.R
I can see the irony in some of the revdep failures. For example this now correctly throws the error that it will not accept any non-dates. devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
# Analogous to current workarounds
ggplot(economics, aes(date, unemploy)) +
geom_line() +
geom_vline(xintercept = as.numeric(as.Date("1983-01-31")))
#> Error in `transformation$transform()` at ggplot2/R/scale-.R:628:3:
#> ! `transform_date()` works with objects of class <Date> only Whereas now the solution is to simply drop the ggplot(economics, aes(date, unemploy)) +
geom_line() +
geom_vline(xintercept = as.Date("1983-01-31")) Created on 2024-05-21 with reprex v2.1.0 |
This comment was marked as resolved.
This comment was marked as resolved.
Numeric input now throws warnings instead of errors: devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
ggplot(economics, aes(date, unemploy)) +
geom_line() +
geom_vline(xintercept = as.numeric(as.Date("1983-01-31")))
#> Warning in scale_x_date(): A <numeric> value was passed to a Date scale.
#> ℹ The value was converted to a <Date> object.
ggplot(economics, aes(as.POSIXct(date), unemploy)) +
geom_line() +
geom_vline(xintercept = as.numeric(as.POSIXct("1983-01-31")))
#> Warning in scale_x_datetime(): A <numeric> value was passed to a Datetime scale.
#> ℹ The value was converted to a <POSIXt/POSIXct> object. Created on 2024-06-04 with reprex v2.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🤞
This PR aims to fix #3342 and fix #4966.
Briefly, all position scales now use the definitions of x- and y-aesthetics from the
gglobal_global
environment.This ensures that rarer position aesthetics, like
xintercept
, contribute to the scale limits and are transformed by the scale.I have been forewarned that this might lead to unexpected issues, but I don't foresee any at the moment. It might lead to some visual changes, but I'd argue they might be intended.
Reprex from #4966:
Created on 2024-01-12 with reprex v2.0.2