move specification of colorspace out of aes() ? #14
Raoul-Kima
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently the colorspace is specified in the aes() call, e.g. fill=rgb_spec(x,y,z) implies a rgb colorspace. The design of the base ggplot2 api is such that these 2 things are separated. The aes call only specifies aesthetics, while the scale_fill_... call specifies how the aesthetic is mapped to a scale and how this scale looks like. For the sake of consistency I suggest doing the same for ggchromatic. So in the aes call one would just write e.g. fill=chromatic(x,y,z).
I guess the question is whether we regard r g and b as three separate aesthetics, in that case it makes sense to specify the colorspace in the aes call, or whether we consider the aesthetic to be "color" and r g and b to be just aspects of this one aesthetic.
Since we only specify one color scale for all dimensions together, it would probably be more consistent to see r g and b as aspects of a single aeasthetic "color", and therefore not specify colorspace in the aes call.
The colorspace specification then could look like: "scale_fill_chromatic(palette=rgb)". Where "rgb" could be "any" function that maps 3 values to a color, such as base::rgb (although that particular one in some cases errors since it doesn't have NA-handling built in). Maybe this is also a good way to separate the functionality of producing multidimensional scales from the implementation of a library of such scales.
This might also make it a bit simpler to implement a custom colorspace, since it might no longer be necessary from an api point of view to code up a custom xyz_spec function, only scale_fill_xyz.
edit: added example of a scale_fill_chromatic call.
Beta Was this translation helpful? Give feedback.
All reactions