I have defined a palette with colorRampPalette
to be used for each plot. How can set this palette by default with ggplot2 ?
I have no idea how to do that and could not find the answer.
MWE :
df <- data.frame(x = letters[1:3], y = runif(3), fill = LETTERS[1:3])
mypalette <- colorRampPalette(colors = c("white", "blue"))
Now how to use the palette itself and not the hack:
ggplot(df, aes(x=x,y=y)) + geom_col(aes(fill = fill)) +
scale_fill_manual(values = mypalette(3))
And more generally speaking, is there something like theme(palette = mypalette)
so has to have always it own palette by default ?
I've found the following strategy sometimes useful: