Skip to content

Review supersession #6389

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

Open
teunbrand opened this issue Apr 1, 2025 · 14 comments · May be fixed by #6449
Open

Review supersession #6389

teunbrand opened this issue Apr 1, 2025 · 14 comments · May be fixed by #6449

Comments

@teunbrand
Copy link
Collaborator

It'd be helpful to review which functions have preferred alternatives and mark them as superseded.
As an example, coord_polar() can be replaced with coord_radial(), but isn't documented like that.
I'd expect some helper functions to be functionally superseded as well.

@teunbrand teunbrand added this to the Editioning milestone Apr 1, 2025
@teunbrand
Copy link
Collaborator Author

teunbrand commented Apr 2, 2025

Let's create a list. It's open for additional suggestions.

Already superseded:

  • coord_flip() by inverting x/y aesthetics.
  • annotation_logticks() by guide_axis_logticks().
  • coord_map() and coord_quickmap() by coord_sf()

Considered for supersession:

  • coord_polar() to be superseded by coord_radial()
  • coord_equal() to be superseded by coord_fixed()
    • Perhaps these could even be incorporated in coord_cartesian(), they are easy to implement.
  • expand_limits() should just be function to be passed to scale limits, e.g. limits = ~ range(.x, value).

@teunbrand
Copy link
Collaborator Author

teunbrand commented May 6, 2025

Behaviour to supersede:

  • options("ggplot2.continuous.colour"): use lifecycle signal superseded. Put superseded badges in documentation. Review documentation and books.

  • supersede plot_env or soft-deprecate. Disentangle facet evaluation wrt plot_env. There is a related issue Drop plot_env from ggplot2 objects? #3994.

TODO: review arguments specifically.

@davidhodge931
Copy link

Could expand_limits not be superseded, please? I know you can do it in the scale via the limits argument with a function, but that is quite complex for a lot of users. It is a common need (e.g. adding a zero), so it's great to have a quick, easy method to do this

@teunbrand
Copy link
Collaborator Author

The problem with expand_limits() is that it is an extragrammatical way for implicitly settings the limits. The term 'limits' would also suggest this works at the scale level, but instead it adds a blank layer. It is hack that might be easy to use, but I'd suggest you're doing users a favour in the long term by instructing on the proper way to manipulate limits.

@davidhodge931
Copy link

Also, the new approach to setting colour palettes does not do entirely what the old options approach does, as you cannot set the NA value with the new approach.

Great to start the process of getting rid of the redundant functions!

@davidhodge931
Copy link

Not everyone needs to learn ggplot2 to an advanced level, @teunbrand

@clauswilke
Copy link
Member

Not everyone needs to learn ggplot2 to an advanced level, @teunbrand

I think discoverability and ability to memorize patterns are both very important for regular users. I don't even know what limits = ~ range(.x, value) does.

In general, I have found that while it's great that there are all these nifty tricks that people can in principle use to get advanced outputs in an elegant way, in practice very few people have the mental capacity to memorize all these tricks and use them in the appropriate circumstances.

Not sure how useful this is in the present context, just pointing this out as something to keep in mind.

@teunbrand
Copy link
Collaborator Author

Separate from this PR, my idea is that there will be limit helper functions in scales, e.g. r-lib/scales#490. Which has the benefits of not being circuitous and being discoverable.

@clauswilke
Copy link
Member

I was debating whether I should bring up the scales package as an example of a repository of great helper functions that can in principle solve all sorts of issues I have and that I can never remember how to use... ;-)

@davidhodge931
Copy link

Oh, those new scales helpers are really nice! +1 for UK spelling limits_centre ;)

While you're looking at supercession ideas, I just remembered this interesting post from a year ago on mastodon re xlim/ylim (& lims by association)
https://mastodon.social/@coolbutuseless@fosstodon.org/112602236033828285

@clauswilke
Copy link
Member

@davidhodge931 We're completely off-topic now, but xlim() and ylim() should be replaced with functions that can modify the existing scale rather than adding a new scale. This is something we've talked about for a long time (#4269). We should be able to change scale properties such as limits, breaks, expansion, etc. without having to replace the existing scale. We just haven't come up with an implementation that is satisfactory.

@smouksassi
Copy link

just to fully agree with Clause's comment
"Very few people have the mental capacity to memorize all these tricks and use them in the appropriate circumstances".
(How many of those exist? :) Teun, Thomas, and ... ? even co-author like Clause find it daunting !)
Maybe Teun's plan is to teach a LLM on how to write ggplot2 code :D ! I have lost track of the various additions, newer and better ways to do things versus the original way, e.g, the dir argument to facet_wrap versus as.table, and so on.
We need a guide for "old guard" ggplot users and also
a guide for new users to adopt the newer, better and more flexible ways.

@thomasp85
Copy link
Member

Let's be clear on what superseding means. It means that there is a new and (in our opinion) better way of doing this. Superseded behaviour is not going away in the way deprecated functionality does. So "the old guard" can continue to do what they've always done. But, if you are a new user you will gently be steered towards the new way of doing things.

@thomasp85
Copy link
Member

Hacks are not necessarily easier to learn than the right way of doing it. It just so happen that these hacks have been internalised by some people who will then feel resistance towards learning a different way. This is not pointing fingers. It is totally understandable. But it is also a poor argument for not superseding a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants