how can I see what colors ggplot2 is using for discrete categories using a given palette, like "Set1" or "Set2" for brewer? i.e. for a given set of categories what the colors that will be used are?
By default it will use hue_pal with certain defaults. When you use scale_x_brewer it will use brewer_pal with certain defaults (both from the scales package). You'll get as many colors from those palettes as you have categories. e.g. (using the defaults):
f <- hue_pal(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1)
f(3)
## [1] "#F8766D" "#00BA38" "#619CFF"
f(9)
## [1] "#F8766D" "#D39200" "#93AA00" "#00BA38" "#00C19F" "#00B9E3" "#619CFF" "#DB72FB"
## [9] "#FF61C3"
g <- brewer_pal(type="seq", palette=1)
g(3)
## [1] "#DEEBF7" "#9ECAE1" "#3182BD"
g(9)
## [1] "#F7FBFF" "#DEEBF7" "#C6DBEF" "#9ECAE1" "#6BAED6" "#4292C6" "#2171B5" "#08519C"
## [9] "#08306B"
You can see what brewer_palwill do with Set3 or any other named palette by using that as the palette parameter.
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