contrast_cols | R Documentation |
Making contrasting colors for use in bar charts.
contrast_cols(n_colors = 3, palette1 = "Pastel 1", palette2 = "Dark 3")
n_colors |
The number of colors you want (integer). |
palette1 |
A qualitative HCL palette from the |
palette2 |
A qualitative HCL palette from the |
The default colors used by ggplot2
are too similar
for neighboring sectors in bar charts, making it difficult to see where one
sector ends and the next starts.
This function creates an alternative vector of colors, by using two different palettes, going from lighter to darker colors, then reverse one of them and finally mixing them taking every second color from each. This mean any two neighboring colors are quite distinct from each other.
You may change the colors by supplying alternative qualitative HCL palettes
from the colorspace
package, see the vignette of this package for
more on what you may choose.
A vector of length n_colors
with colors.
Lars Snipen.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.