I am using RColorBrewer (palette = "Set2"). I would like to extract the list of colors and use them for annotations. Is there a way to extract a vector of Set2 colors (call it List) and use that to make an annotation match the color already in use (color=List(3))?
Thank you.
You can extract the 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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With