Experimental. The interface of scale_cheysson() and aes_cheysson()
may change in a future version.
Usage
scale_cheysson(
palette = "1881_12",
reverse = FALSE,
aesthetics = c("fill", "pattern", "pattern_fill", "pattern_fill2", "pattern_angle"),
na.value = "grey80",
...
)
aes_cheysson(x, ...)Arguments
- palette
Name of palette (e.g., "1883_30") or palette type ("sequential", "diverging", "grouped", "category"). See cheysson_patterns.
- reverse
Whether to reverse the palette order. Default is FALSE.
- aesthetics
Which aesthetics to provide scales for: any of
"fill","pattern","pattern_fill","pattern_fill2","pattern_angle". Default is all of them. A scale for an aesthetic that the plot does not map has no effect.- na.value
Color for missing values, used for the fill and line colors; missing values get no hatching (
pattern = "none").- ...
For
scale_cheysson(): additional arguments passed to every scale, e.g.nameorlabels; since all the scales get the samename, their legends stay merged into one. Foraes_cheysson(): other aesthetic mappings to include, e.g.xandy.- x
The variable to map, as in
ggplot2::aes().
Value
scale_cheysson() returns a list of ggplot2 discrete scales, which
can be added to a plot with + like a single scale.
aes_cheysson() returns an aesthetic mapping of x to fill,
pattern, pattern_fill, pattern_fill2 and pattern_angle, plus any
mappings in ....
Details
Cheysson's palettes combine colors with hatching: each element of a
palette has a paper or fill color, a hatch type (solid, stripe or
crosshatch), a line color and an angle. Drawing them with 'ggpattern'
takes one scale per aesthetic (scale_fill_cheysson_pattern(),
scale_pattern_type_cheysson(), scale_pattern_fill_cheysson(), ...).
scale_cheysson() adds all of them with a single +, and
aes_cheysson() maps one variable to all of the matching aesthetics.
All the scales take their values from the same elements of the palette, so
each level of the mapped variable gets one complete historical swatch.
The aesthetics must be mapped for the scales to apply: a scale for
pattern_fill does nothing unless pattern_fill is mapped, and 'ggpattern'
then draws grey hatching. aes_cheysson() maps them all.
Parameters that are better set to fixed values in the geom are not
included: pattern_density and pattern_spacing (the palettes' spacings
were measured on small swatches, see the Guerry maps vignette),
pattern_colour (NA avoids outlines around the hatch lines) and the
outline colour.
See also
scale_pattern_cheysson for the individual scales,
cheysson_pattern() for the underlying pattern specifications.
Examples
# \donttest{
if (requireNamespace("ggpattern", quietly = TRUE)) {
library(ggplot2)
library(ggpattern)
data <- data.frame(
category = LETTERS[1:5],
value = c(15, 23, 18, 20, 12)
)
ggplot(data, aes(category, value)) +
geom_col_pattern(aes_cheysson(category),
pattern_colour = NA, pattern_density = 0.35,
colour = "black") +
scale_cheysson("1883_30") +
theme_minimal()
}
# }
