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

Just checking - no continuous functionality? #16

Open
jzadra opened this issue Nov 14, 2019 · 2 comments
Open

Just checking - no continuous functionality? #16

jzadra opened this issue Nov 14, 2019 · 2 comments

Comments

@jzadra
Copy link

jzadra commented Nov 14, 2019

I juist wanted to confirm that this package doesn't support continuous scales? I'm not missing anything?

@dnkent
Copy link

dnkent commented Jan 20, 2021

@jzadra, ran across this question while looking for an option to produce more than 8 colors. In my case, I ended up putting together this hacky fix for creating a lengthier palette based on the colorblindr defaults. Once the palette is generated, then it can be inserted into ggplot with scale_fill_manual(values = colorblindr_cont).

When my monitor is set to grayscale it seems to generally maintain the desired colorblindr differentiation. Maybe this will work for your needs or be easily adjusted if not?

library(RColorBrewer)

gen_palette <- function(data, var){
  n_colors <- length(unique(data[, var])) # number of unique values for var
  color_pal <- c(
    "#E69F00", "#56B4E9", "#009E73", "#F0E442",
    "#0072B2", "#D55E00", "#CC79A7", "#000000"
  )
  custom_colors <- colorRampPalette(color_pal)(n_colors)
  return(custom_colors)
}

colorblinr_cont <- gen_palette(data = dataset, var = "varname")

@jzadra
Copy link
Author

jzadra commented Jan 20, 2021

Thanks!

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