-
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
Warning from guide_axis() with 3.5.0 rc #5684
Comments
A simpler reprex: library(maps)
library(ggplot2)
nz <- map_data("nz")
ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black") +
coord_map() +
guides(x = guide_axis(angle = 45))
#> Warning: `guide_axis()` cannot be used for .
#> ℹ Use one of x, y, or r instead. Created on 2024-02-07 with reprex v2.1.0 The underlying issue is that library(maps)
library(ggplot2)
nz <- map_data("nz")
ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black") +
coord_sf(crs = 4326) +
guides(x = guide_axis(angle = 45)) Created on 2024-02-07 with reprex v2.1.0 |
I'm going to close this, as we're unlikely to update |
While I do understand your reasoning here, I think calling
is in the definition of superseded and while you haven't changed Guess I need to figure out the correct incantation for |
A couple of points:
library(maps)
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.4.2'
nz <- map_data("nz")
ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black") +
coord_map() +
guides(x = guide_axis(angle = 45)) Created on 2024-02-23 with reprex v2.1.0
library(maps)
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.5.0.9000'
nz <- map_data("nz")
ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black") +
coord_map() +
theme(axis.text.x.bottom = element_text(angle = 45, hjust = 1, vjust = 1)) Created on 2024-02-23 with reprex v2.1.0
|
Sorry, I should have been clearer; I shouldn't have implied the code "worked" in the sense that the tick labels were rotated. I meant from the point of view of running without warning. That the guides thing doesn't work in earlier versions of ggplot is not a gratia problem but a ggplot2 problem (that I admittedly didn't catch at the time all this got written) - I was trying to have a consistent way of changing the angle of axis labels across multiple different types on plot in the package and was using
That's semantics when you are talking about using ggplot in a package that is on CRAN. If you pushed this rc to CRAN today, my package would be broken as far as CRAN is concerned because it now emits a warning. While I appreciate there is an easy fix for the average user (just ignore the warning or use |
I concede that the meaning of "superseded" is somewhat ambiguous when it comes to modular APIs like ggplot2, but I don't think we are interpreting it wrong (but clearly different than you). If a function is superseded the promise is that code that worked prior to the superseding will continue to work. That promise is uphold here. We do not want to mark the function as deprecated as a few still find it valuable, but it is vestigal and users cannot expect new functionality (which the new guide system is) to work with it |
@thomasp85 I guess this is a clash between the "User" use-case and the "Developer" use-case, which lifecycle doesn't seem to address, but, from the lifecycle descriptions of the statuses
is ambiguous as I guess the warning that I report here is not a) from lifecycle, nor b) from I's almost as though lifecycle needs a deprecated-for-developers status, but that's not something for discussion here. Thanks both! |
I emphasise with that viewpoint. However, I would actually argue that your old code using I don't think your reading of "A superseded function will not emit a warning..." is correct. In my head it references the warnings from lifecycle as it talks about the differences to a deprecated function. The alternative would be quite crazy, i.e. a superseded function will never emit a warning no matter whether you use it correctly |
If we're not talking about a highly modular system like ggplot2, then I would expect That's my view from the developer perspective. I appreciate that from the user-perspective, deprecating When it comes to highly modular packages, I would view it as still a whole that should work together. Once things stop working together, frustrations will kick in when users try to do something perfectly valid with one module of ggplot that no-longer works with the other module. In that case I would just bite the bullet and deprecate the thing that no-longer works with the new and improved module. (The above is ignoring the issue that Where would you draw the line? Where would you deprecate In this instance, moving to use the suggested function that has superseded |
My point above was that your code was not perfectly correct, even in the old version. It was a bug that it did not throw a warning. This bug has been fixed now and would have been irrespective of the state of the function |
But But the change to |
|
@gavinsimpson Out of curiousity, did you ever get the email from CRAN about this? |
In the end, no; I think you'd fixed some things that were causing errors and warnings that I got a bug report over and to keep testing time down this particular functionality was being skipped on CRAN. I've since swapped out the |
While checking out the changes to the guides in the 3.5.0 release candidate I found an issue with
guide_axis()
that represents a difference over 3.4.0 behaviour.I've tried to make this as minimal as I can without my actually doing a lot of work with maps/projections. From my limited testing, I needed something this complicated as simple usage of
guide_axis()
worked as expected.The regexp below simulates data on a sphere, fits a GAM to those data using mgcv and a spline on the sphere basis, and then plots the estimated spline using
coord_map()
to produce an orthographic projection.Created on 2024-02-07 with reprex v2.1.0
I expected no warning as all I'm trying to do is change the angle of the tick labels on the x axis.
I'll also note that this plot doesn't actually have an ticks on either the x or y axis; which I assume is expected given the plot is of the whole globe?
Note that a more elaborate version of this code is used in an R package where this kind of plot could be used to plot any area of the globe.
Here's another example of the same behaviour but which illustrates that
guide_axis()
doesn't change the angle of the tick labels, but which requires installation of the {gamair} package:Created on 2024-02-07 with reprex v2.1.0
This version illustrates that the
guides_axis()
doesn't change the angle of the tick labelsI expected that there would be no warning, and the tick labels on the x axis would be drawn at 45 degrees to the axis.
session info
Output from
sessioninfo::session_info()
The text was updated successfully, but these errors were encountered: