How many type of colors in a palette.

I do some research on this topic.

  1. use the package wesanderson, I can run this script to get how many type of colors in a palette.
wes_palette("Royal1") %>% length
#> [1] 4

Created on 2019-03-21 by the reprex package (v0.2.1)

  1. However, I don't how to do it for the function scale_fill_brewer, the fastest way now for me is to check this picture from Cookbook for R and count it.

1 Like

The object has all the detail you want. If you wanted a process for narrowing it down, you could do something like:

# dependencies

# displacy a single item %>%
  rownames_to_column(var = "name") %>%
  filter(name == "OrRd")
#>   name maxcolors category colorblind
#> 1 OrRd         9      seq       TRUE

Created on 2019-03-20 by the reprex package (v0.2.1)

Hi @chris.prener, thanks for your quick solution. is cool and really useful. And your analysis to narrow it down is inspirational. %>% 
   rownames_to_column('color') %>% 
   ggplot(aes(fct_reorder(color,maxcolors), maxcolors)) +
   geom_col() +

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.