Allow for discrete colors
andrewheiss opened this issue · 2 comments
andrewheiss commented
Viridis includes a discrete = TRUE
argument in scale_*_viridis()
that allows the colors to be discretized. And with the most recent version of ggplot2/viridis, there are now two types of scales: scale_*_viridis_c()
and scale_*_viridis_d()
Currently scale_*_scico()
only works with continuous colors and the only way to get discrete colors is to generate a palette with scico(x)
and use the hex values manually.
It would be nice to add discretization to the scale_*_scico()
functions and bring it in line with viridis.
andrewheiss commented
Here's a reprex:
library(tidyverse)
library(scico)
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
# Using scale_color_viridis_d()
ggplot(dsamp, aes(carat, price)) +
geom_point(aes(colour = clarity)) +
scale_color_viridis_d(begin = 0.2)
# Can't use scale_color_scico()
ggplot(dsamp, aes(carat, price)) +
geom_point(aes(colour = clarity)) +
scale_color_scico(begin = 0.2)
# Error: Discrete value supplied to continuous scale
# Can use scio() within scale_color_manual(), but must manually specify the n
ggplot(dsamp, aes(carat, price)) +
geom_point(aes(colour = clarity)) +
scale_color_manual(values = scico(8, begin = 0.2, palette = "roma"))
thomasp85 commented
Thanks. I think @clauswilke already convinced me to add it but good with an issue to remind me