library("ggplot2")
df <- data.frame(
x = runif(100),
y = runif(100),
z1 = rnorm(100),
z2 = abs(rnorm(100))
)
p <- ggplot(df, aes(x, y)) + geom_point(aes(colour = z2))
palettes <-
ggthemes_data[["tableau"]][["color-palettes"]][["ordered-diverging"]]
for (palette in head(names(palettes))) {
print(p + scale_colour_gradient2_tableau(palette) +
ggtitle(palette))
}
# If you need to reverse a palette, use a transformation
p + scale_colour_gradient2_tableau(trans = "reverse")
Run the code above in your browser using DataLab