data("iris")
iris$Species2 <- factor(rep(c(1:10), each = 15))
# Generate a gradient of 10 colors
ggscatter(iris, x = "Sepal.Length", y = "Petal.Length",
color = "Species2",
palette = get_palette(c("#00AFBB", "#E7B800", "#FC4E07"), 10))
# Scatter plot with default color palette
ggscatter(iris, x = "Sepal.Length", y = "Petal.Length",
color = "Species")
# RColorBrewer color palettes
ggscatter(iris, x = "Sepal.Length", y = "Petal.Length",
color = "Species", palette = get_palette("Dark2", 3))
# ggsci color palettes
ggscatter(iris, x = "Sepal.Length", y = "Petal.Length",
color = "Species", palette = get_palette("npg", 3))
# Custom color palette
ggscatter(iris, x = "Sepal.Length", y = "Petal.Length",
color = "Species",
palette = c("#00AFBB", "#E7B800", "#FC4E07"))
# Or use this
ggscatter(iris, x = "Sepal.Length", y = "Petal.Length",
color = "Species",
palette = get_palette(c("#00AFBB", "#FC4E07"), 3))
Run the code above in your browser using DataLab