Closed
Description
The current ggplot2 has support for aesthetic aliases, such as color
instead of colour
. 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:
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 alias point_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:
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:
Lines 554 to 571 in eecc450
and here:
Lines 620 to 632 in eecc450