I do some research on this topic.
use the package wesanderson
, I can run this script to get how many type of colors in a palette .
library(wesanderson)
library(magrittr)
wes_palette("Royal1") %>% length
#> [1] 4
Created on 2019-03-21 by the reprex package (v0.2.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.
library(RColorBrewer)
display.brewer.all()
1 Like
The brewer.pal.info
object has all the detail you want. If you wanted a process for narrowing it down, you could do something like:
# dependencies
suppressMessages(library(dplyr))
library(tibble)
library(RColorBrewer)
# displacy a single item
brewer.pal.info %>%
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.
brewer.pal.info
is cool and really useful. And your analysis to narrow it down is inspirational.
brewer.pal.info %>%
rownames_to_column('color') %>%
ggplot(aes(fct_reorder(color,maxcolors), maxcolors)) +
geom_col() +
coord_flip()
1 Like
system
Closed
March 28, 2019, 12:25am
4
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.