Possible Duplicate:
How to extract the fill colours from a ggplot object?
In an arbitrary ggplot plot, say
p <- ggplot(data=PlantGrowth, aes(x=group, y=weight, fill=group)) + geom_boxplot()
is there a way to extract the code of the colors that were used (i.e. the variable named "values" that we modify with the command
p + scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9"))
) ?
I would like to get the colors used in order to modify only one.
Thank you,
François
For a discrete scale (with default setting scale_colour_hue
) the function hue_pal
in package scales
is used.
E.g., with three factor levels:
R> library(scales)
R> scales::hue_pal()(3)
[1] "#F8766D" "#00BA38" "#619CFF"
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