-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Improved support for aesthetic aliases #2649
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
@hadley expressed concern about user-modifiable aesthetics. I can see how that could be an issue, if e.g. An alternative approach might be to simply define a much larger set of aesthetic aliases in ggplot2. Real problems (such as #2674) arise only from the British/US spelling of color/colour, so all we'd have to do is define variants of |
Two more possibilities, brought up here:
Regardless of other pros and cons of these options, I think they both suffer from the same technical problem: Aesthetics are renamed in the Lines 77 to 83 in c1908f1
and aes() is usually called early in plot construction, before themes or layers are defined. So it's not clear how aesthetic definitions in the theme or layer could be made available to aes() in, e.g., the ggplot() call.
|
Does renaming matter though? I think it’s important for historical reasons, but I don’t think it’s needed for new aesthetics. |
It's all about the color/colour spelling differences. Currently On further reflection, maybe the right solution is to just use a regular expression and replace any substring |
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/ |
The current ggplot2 has support for aesthetic aliases, such as
color
instead ofcolour
. However, there are two places where this support could be improved, and they should be tackled at the same time, I think.1. Make aliases configurable
Currently the available aliases are hardcoded here:
ggplot2/R/aes.r
Lines 10 to 23 in eecc450
I suspect most users are not even aware of some of those, e.g.
"srt" = "angle"
. More importantly, it is currently not possible to create new aliases. So, if a package creates a new aesthetic, e.g.point_colour
, it cannot create an aliaspoint_color
. The solution would be to provide functions that can add (and subtract?) aliases to (from) the default list. I would like to point out that this is conceptually similar to #2540 (user-defined theme elements), and similar techniques and user interfaces could be used in both cases.2. Apply aliases to scales as well
Aliases are not applied to
aesthetics
arguments of scales. This leads to confusing behavior such as the following:Created on 2018-05-21 by the reprex package (v0.2.0).
The solution is to rename aesthetics in the scales, just as it is done in the layers. There are only two places where this needs to happen, here:
ggplot2/R/scale-.r
Lines 554 to 571 in eecc450
and here:
ggplot2/R/scale-.r
Lines 620 to 632 in eecc450
The text was updated successfully, but these errors were encountered: