Colour and fill scales for ggplot2
plots, using object of class palettehex
.
Usage
scale_colour_palettehex_d(x, which = 1, reverse = FALSE, ...)
scale_color_palettehex_d(x, which = 1, reverse = FALSE, ...)
scale_fill_palettehex_d(x, which = 1, reverse = FALSE, ...)
scale_colour_palettehex_c(x, which = 1, reverse = FALSE, ...)
scale_color_palettehex_c(x, which = 1, reverse = FALSE, ...)
scale_fill_palettehex_c(x, which = 1, reverse = FALSE, ...)
Arguments
- x
object of class
palettehex
- which
selection of which palette of a set to choose. Either by name, id or numeric index.
- reverse
logical. If scale should b reversed (default: FALSE)
- ...
arguments to be passed to
discrete_scale
Details
The palettehex
class is a data.frame of
many palettes. This function takes such a data.frame
and a choice of palette by name, id or numeric index
can be made for the scale.
Functions
scale_colour_palettehex_d()
: Discrete colour scalescale_color_palettehex_d()
: Discrete colour scalescale_fill_palettehex_d()
: Discrete fill scalescale_colour_palettehex_c()
: Continuous colour scalescale_color_palettehex_c()
: Continuous colour scalescale_fill_palettehex_c()
: Continuous fill scale
Examples
if(curl::has_internet()){
library(ggplot2)
x <- get_popular_palettes()
ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_palettehex_c(x)
ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_palettehex_c(x, 3)
ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_palettehex_d(x)
ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_palettehex_d(x, 1872)
}
#> Warning: Removed 32 rows containing missing values (`geom_point()`).