Improved support for aesthetic aliases #2649
The current ggplot2 has support for aesthetic aliases, such as
1. Make aliases configurable
Currently the available aliases are hardcoded here:
I suspect most users are not even aware of some of those, e.g.
2. Apply aliases to scales as well
Aliases are not applied to
library(ggplot2) # works ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + scale_color_viridis_d(aesthetics = "colour")
# does not work ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + scale_color_viridis_d(aesthetics = "color")
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:
The text was updated successfully, but these errors were encountered:
@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
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