You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to compose bivariate color scales with arbitrary dimensions to accommodate ordered factors. This feature would expand use of this package to a broader set of data that could benefit from a cross-classified color scale. For example, a bivariate color scale might allow an ordered factor (low vs. high) to be encoded as lightness or saturation variants of the other dimension's color scale.
I'm imagining a color scale that looks something like this:
Proposed solution
I think bi_class is the main function that would need modification. The style and dim would gain the option of being specified as vectors of length 2 corresponding to the argument values to use for x and y. style would also gain a new possible value, something like ordered, factor, or levels. This option would retrieve the unique values of the variable rather than trying to calculate breaks as for a continuous variable. (Add a warning here if the variable isn't ordered.)
In the above figure, this solution would look something like: bi_class(.data, x = ord, y = cont, style = c("levels", "quantile"), dim = c(2, 3))
Some careful thought is needed to ensure that the color modification for the factor doesn't cause collisions. If willing to add a dependency, colorspace has some nice functions for automating the calculation of lightened or desaturated colors for an arbitrary number of levels. An additional argument might allow the user to specify the type of color modification (lighten vs. desaturate) and the corresponding amounts of adjustment for each factor level (e.g., lightening 0 and 0.4).
Reprex
The code below reproduces the figure above.
I would like to compose bivariate color scales with arbitrary dimensions to accommodate ordered factors. This feature would expand use of this package to a broader set of data that could benefit from a cross-classified color scale. For example, a bivariate color scale might allow an ordered factor (low vs. high) to be encoded as lightness or saturation variants of the other dimension's color scale.
I'm imagining a color scale that looks something like this:

Proposed solution
I think
bi_class
is the main function that would need modification. Thestyle
anddim
would gain the option of being specified as vectors of length 2 corresponding to the argument values to use for x and y.style
would also gain a new possible value, something likeordered
,factor
, orlevels
. This option would retrieve the unique values of the variable rather than trying to calculate breaks as for a continuous variable. (Add a warning here if the variable isn't ordered.)In the above figure, this solution would look something like:
bi_class(.data, x = ord, y = cont, style = c("levels", "quantile"), dim = c(2, 3))
Some careful thought is needed to ensure that the color modification for the factor doesn't cause collisions. If willing to add a dependency,
colorspace
has some nice functions for automating the calculation of lightened or desaturated colors for an arbitrary number of levels. An additional argument might allow the user to specify the type of color modification (lighten vs. desaturate) and the corresponding amounts of adjustment for each factor level (e.g., lightening 0 and 0.4).Reprex
The code below reproduces the figure above.
The text was updated successfully, but these errors were encountered: