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
{{ message }}
Repository navigation
Could support the use of function factories like scales::pal_hue() and scales::pal_viridis()? #5843
changed the title [-]Could colour/fill scales support the use of function factories like `scales::pal_hue()` and `scales::pal_viridis()`?[/-][+]Could support the use of function factories like `scales::pal_hue()` and `scales::pal_viridis()`?[/+]on Apr 15, 2024
This has been on my mind as well to make the interface between scales and palettes somewhat smoother.
Your first example can be replaced with discrete_scale("colour", palette = scales::pal_hue()), but this is not so much the case for the continuous examples.
For this to happen, I think {scales} needs to start describing palette functions more so that some properties are easily queried.
Useful properties to know about palettes are:
Is it continuous, i.e. does it accept values in the (0, 1) range.
Is it discrete, i.e. does it accept n values.
If discrete, what is the maximum n it will accept?
Do they have built-in NA handlers (e.g. via scales::colour_ramp())?
If we know this, we can automatically expand discrete palettes to continuous ones by using e.g. colour_ramp(discrete_pal()(n_max)), or discretise continuous palettes by using continuous_pal()(seq(0, 1, length.out = n).
Activity
[-]Could colour/fill scales support the use of function factories like `scales::pal_hue()` and `scales::pal_viridis()`?[/-][+]Could support the use of function factories like `scales::pal_hue()` and `scales::pal_viridis()`?[/+]teunbrand commentedon Apr 15, 2024
This has been on my mind as well to make the interface between scales and palettes somewhat smoother.
Your first example can be replaced with
discrete_scale("colour", palette = scales::pal_hue()), but this is not so much the case for the continuous examples.For this to happen, I think {scales} needs to start describing palette functions more so that some properties are easily queried.
Useful properties to know about palettes are:
nvalues.nit will accept?NAhandlers (e.g. viascales::colour_ramp())?If we know this, we can automatically expand discrete palettes to continuous ones by using e.g.
colour_ramp(discrete_pal()(n_max)), or discretise continuous palettes by usingcontinuous_pal()(seq(0, 1, length.out = n).