# NOT RUN {
library("ggplot2")
# default colors with slightly darkened midpoint
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() + theme_minimal() +
scale_color_discrete_diverging(l2=75)
# color scale "Green-Orange"
ggplot(iris, aes(Sepal.Length, fill = Species)) +
geom_density(alpha = 0.7) + theme_classic() +
scale_fill_discrete_diverging(palette = "Green-Orange", rev = TRUE)
# use `nmax` and `order` to skip some colors
ggplot(iris, aes(Sepal.Length, fill = Species)) +
geom_density(alpha = 0.7) + theme_classic() +
scale_fill_discrete_diverging(palette = "Green-Orange", nmax = 5, order = c(1, 4, 5))
# }
Run the code above in your browser using DataCamp Workspace