knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 8, fig.height = 5.5, warning = FALSE, message = FALSE ) if (!requireNamespace("patchwork", quietly = TRUE)) { knitr::opts_chunk$set(eval = FALSE) }
This vignette can be referred to by citing the package:
citation("see")
Before we start, we create some data sets with three, four and five groups; one is useful to demonstrate line-geoms, the iris-dataset is used for point-geoms.
library(ggplot2) library(see) data(iris) iris$group4 <- as.factor(sample(1:4, size = nrow(iris), replace = TRUE)) iris$group5 <- as.factor(sample(1:5, size = nrow(iris), replace = TRUE)) d1 <- data.frame( x = rep(1:20, 3), y = c( seq(2, 4, length.out = 20), seq(3, 6, length.out = 20), seq(5, 3, length.out = 20) ), group = rep(factor(1:3), each = 20) ) d2 <- data.frame( x = rep(1:20, 4), y = c( seq(2, 4, length.out = 20), seq(3, 6, length.out = 20), seq(5, 3, length.out = 20), seq(4, 2.5, length.out = 20) ), group = rep(factor(1:4), each = 20) ) d3 <- data.frame( x = rep(1:20, 5), y = c( seq(2, 4, length.out = 20), seq(3, 6, length.out = 20), seq(5, 3, length.out = 20), seq(4, 2.5, length.out = 20), seq(3.5, 4.5, length.out = 20) ), group = rep(factor(1:5), each = 20) ) theme_set(theme_abyss(legend.position = "bottom"))
There are several different color scales available
in the see package, most of them having some pre-defined palettes like
"full"
, "ice"
, "rainbow"
, "complement"
, "contrast"
, or "light"
-
exceptions are the pizza color scale and
bluebrown color scale.
In this vignettes, we show the "light"
palettes for the different color scales
to give an impression how these scales work with different type of data,
especially for dark themes.
p1 <- ggplot(d1, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_social(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) + geom_point2(size = 2.5) + scale_color_social(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d2, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_social(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group4)) + geom_point2(size = 2.5) + scale_color_social(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d3, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_social(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group5)) + geom_point2(size = 2.5) + scale_color_social(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d1, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_material(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) + geom_point2(size = 2.5) + scale_color_material(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d2, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_material(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group4)) + geom_point2(size = 2.5) + scale_color_material(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d3, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_material(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group5)) + geom_point2(size = 2.5) + scale_color_material(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d1, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_flat(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) + geom_point2(size = 2.5) + scale_color_flat(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d2, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_flat(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group4)) + geom_point2(size = 2.5) + scale_color_flat(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d3, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_flat(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group5)) + geom_point2(size = 2.5) + scale_color_flat(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d1, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_metro(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) + geom_point2(size = 2.5) + scale_color_metro(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d2, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_metro(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group4)) + geom_point2(size = 2.5) + scale_color_metro(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d3, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_metro(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group5)) + geom_point2(size = 2.5) + scale_color_metro(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d1, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_see(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) + geom_point2(size = 2.5) + scale_color_see(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d2, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_see(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group4)) + geom_point2(size = 2.5) + scale_color_see(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d3, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_see(palette = "light") p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group5)) + geom_point2(size = 2.5) + scale_color_see(palette = "light") plots(p1, p2, n_rows = 1)
p1 <- ggplot(d1, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_pizza() p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) + geom_point2(size = 2.5) + scale_color_pizza() plots(p1, p2, n_rows = 1)
p1 <- ggplot(d2, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_pizza() p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group4)) + geom_point2(size = 2.5) + scale_color_pizza() plots(p1, p2, n_rows = 1)
p1 <- ggplot(d3, aes(x, y, colour = group)) + geom_line(linewidth = 1) + scale_color_pizza() p2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = group5)) + geom_point2(size = 2.5) + scale_color_pizza() plots(p1, p2, n_rows = 1)
theme_set(theme_minimal()) d <- data.frame( x = names(social_colors()) ) p1 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = social_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) d <- data.frame( x = names(flat_colors()) ) p2 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = flat_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) d <- data.frame( x = names(material_colors()) ) p3 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = material_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) d <- data.frame( x = names(metro_colors()) ) p4 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = metro_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) d <- data.frame( x = names(see_colors()) ) p5 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = see_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) d <- data.frame( x = names(pizza_colors()) ) p6 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = pizza_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) d <- data.frame( x = names(bluebrown_colors()) ) p7 <- ggplot(d, aes(x, fill = x)) + geom_bar(width = 0.9) + scale_fill_manual(values = bluebrown_colors()) + scale_y_continuous(labels = NULL, expand = c(0, 0)) + guides(fill = "none") + ylab(NULL) + xlab(NULL) + theme( axis.text.x = element_text(angle = 90), panel.grid = element_blank() ) plots( p1, p2, p3, p4, p5, p6, p7, n_columns = 1, tags = c( "Social", "Flat", "Material", "Metro", "See", "Pizza", "Bluebrown" ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.