-
Notifications
You must be signed in to change notification settings - Fork 2k
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
NA
limits in coords
#2907
Comments
There's another inconsistency among Thus, in library(ggplot2)
scale_range <- function(scale, limits = NULL, expand = TRUE) {
expansion <- if (expand) ggplot2:::expand_default(scale) else c(0, 0)
if (is.null(limits)) {
scale$dimension(expansion)
} else {
limits <- ifelse(is.na(limits), scale$get_limits(), limits)
range <- range(scale$transform(limits))
scales::expand_range(range, expansion[1], expansion[2])
}
}
assignInNamespace("scale_range", scale_range, ns = "ggplot2")
ggplot(cars, aes(speed, dist)) +
geom_point() +
coord_cartesian(ylim = c(25, NA, NA)) Created on 2018-11-23 by the reprex package (v0.2.1) I think
Is there any reason that |
I just tried to do this too! |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Setting
NA
in limits ofcoords
in a similar fashion toscales
ends up in an error.Created on 2018-09-21 by the reprex package (v0.2.0).
I've tinker a bit and found that the error is in this line:
ggplot2/R/coord-cartesian-.r
Line 121 in 01155ba
Adding this:
limits <- ifelse(is.na(limits), scale$get_limits(), limits)
solves the issue in this case.
Created on 2018-09-21 by the reprex package (v0.2.0).
I'm not versed enough on how
ggplot2
handles coords to know if it's a robust fix across different coords, though.The text was updated successfully, but these errors were encountered: