Extracting the RColorBrewer palette for another use

I am using RColorBrewer (palette = "Set2"). I would like to extract a list of colors and use them for annotations. Is there a way to extract the Set2 color vector (call it List) and use that to make the annotation match the color already in use (color = List (3))?

Thank.

+3


source to share


1 answer


You can highlight colors like this



library(RColorBrewer)
f <- function(pal) brewer.pal(brewer.pal.info[pal, "maxcolors"], pal)
(cols <- f("Set1"))
# [1] "#E41A1C" "#377EB8" "#4DAF4A" "#984EA3" "#FF7F00" "#FFFF33" "#A65628" "#F781BF" "#999999"

      

+4


source







All Articles