View source: R/gg_color_swatches.R
gg_color_swatches | R Documentation |
scale_fill_*
mechanismThis 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.
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))
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 |
gg_color_swatches(8) + scale_fill_OkabeIto()
gg_color_swatches(10) + ggtitle("Default ggplot2 discrete color scale")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.