gg_color_swatches: Generate a set of color swatches to be colored via ggplot2's...

View source: R/gg_color_swatches.R

gg_color_swatchesR Documentation

Generate a set of color swatches to be colored via ggplot2's scale_fill_* mechanism

Description

This function is similar to palette_plot, with two main differences: First, unlike palette_plot, gg_color_swatches cannot label the colors with their hex code. Second, the colors don't need to be provided as an argument, the resulting plot can be directly styled by adding a scale_fill_* expression. Thus, this function is particularly useful to visualize existing ggplot2 color scales.

Usage

gg_color_swatches(n = 10, xmargin = 0.2, ymargin = 0, title = NULL,
  title_size = 14, title_family = "", title_face = "plain",
  plot_margin = margin(title_size/2, title_size/2, title_size/2,
  title_size/2))

Arguments

n

Number of color swatches to generate

xmargin

Fraction of each swatch to be used as margin in the x direction

ymargin

Fraction of each swatch to be used as margin in the y direction

title

Optional title to print above the color swatches. Can also be provided via ggtitle.

title_size

Font size of the title

title_family

Font family of the title

title_face

Font face of the title

plot_margin

Margin around the plot, specified via the ggplot2 function margin

Examples

gg_color_swatches(8) + scale_fill_OkabeIto()
gg_color_swatches(10) + ggtitle("Default ggplot2 discrete color scale")

clauswilke/colorblindr documentation built on July 29, 2023, 2:17 p.m.