View source: R/scale-pattern-brewer.R
scale_pattern_colour_brewer | R Documentation |
The brewer
scales provides sequential, diverging and qualitative
colour schemes from ColorBrewer. These are particularly well suited to
display discrete values on a map. See https://colorbrewer2.org for
more information.
scale_pattern_colour_brewer(
...,
type = "seq",
palette = 1,
direction = 1,
aesthetics = "pattern_colour"
)
scale_pattern_fill_brewer(
...,
type = "seq",
palette = 1,
direction = 1,
aesthetics = "pattern_fill"
)
scale_pattern_fill2_brewer(
...,
type = "seq",
palette = 1,
direction = 1,
aesthetics = "pattern_fill2"
)
scale_pattern_colour_distiller(
...,
type = "seq",
palette = 1,
direction = -1,
values = NULL,
space = "Lab",
na.value = "grey50",
guide = guide_colourbar(available_aes = "pattern_colour"),
aesthetics = "pattern_colour"
)
scale_pattern_fill_distiller(
...,
type = "seq",
palette = 1,
direction = -1,
values = NULL,
space = "Lab",
na.value = "grey50",
guide = guide_colourbar(available_aes = "pattern_fill"),
aesthetics = "pattern_fill"
)
scale_pattern_fill2_distiller(
...,
type = "seq",
palette = 1,
direction = -1,
values = NULL,
space = "Lab",
na.value = "grey50",
guide = guide_colourbar(available_aes = "pattern_fill2"),
aesthetics = "pattern_fill2"
)
... |
Other arguments passed on to |
palette |
If a string, will use that named palette. If a number, will index into
the list of palettes of appropriate |
direction , type , aesthetics , values , space , na.value , guide |
See |
The brewer
scales were carefully designed and tested on discrete data.
They were not designed to be extended to continuous data, but results often
look good. Your mileage may vary.
A ggplot2::Scale object.
The following palettes are available for use with these scales:
BrBG, PiYG, PRGn, PuOr, RdBu, RdGy, RdYlBu, RdYlGn, Spectral
Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3
Blues, BuGn, BuPu, GnBu, Greens, Greys, Oranges, OrRd, PuBu, PuBuGn, PuRd, Purples, RdPu, Reds, YlGn, YlGnBu, YlOrBr, YlOrRd
Modify the palette through the palette
arguement.
The distiller
scales extend brewer to continuous scales by smoothly
interpolating 7 colours from any palette to a continuous scale. The fermenter
scales provide binned versions of the brewer scales.
if (require("ggplot2")) {
df <- data.frame(level = c("a", "b", "c", "d"),
outcome = c(2.3, 1.9, 3.2, 1))
# discrete 'brewer' palette
gg <- ggplot(df) +
geom_col_pattern(
aes(level, outcome, pattern_fill = level),
pattern = 'stripe',
fill = 'white',
colour = 'black'
) +
theme_bw(18) +
scale_pattern_fill_brewer()
plot(gg)
# continuous 'distiller' palette
gg <- ggplot(df) +
geom_col_pattern(
aes(level, outcome, pattern_fill = outcome),
pattern = 'stripe',
fill = 'white',
colour = 'black'
) +
theme_bw(18) +
scale_pattern_fill_distiller()
plot(gg)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.