Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for discrete colors #2

Closed
andrewheiss opened this issue Jun 1, 2018 · 2 comments
Closed

Allow for discrete colors #2

andrewheiss opened this issue Jun 1, 2018 · 2 comments

Comments

@andrewheiss
Copy link

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
Copy link
Author

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
Copy link
Owner

Thanks. I think @clauswilke already convinced me to add it but good with an issue to remind me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants