Colour and fill scales for ggplot2
plots, using object of class colorhex
as basis for colour choices.
Usage
scale_colour_colorhex_d(x, type = "triadic", reverse = FALSE, ...)
scale_color_colorhex_d(x, type = "triadic", reverse = FALSE, ...)
scale_fill_colorhex_d(x, type = "triadic", reverse = FALSE, ...)
scale_colour_colorhex_c(x, type = "complementary", reverse = FALSE, ...)
scale_color_colorhex_c(x, type = "complementary", reverse = FALSE, ...)
scale_fill_colorhex_c(x, type = "complementary", reverse = FALSE, ...)
Arguments
- x
object of class
colorhex
- type
character. Type of colours to use. One of c("complementary", "triadic" (default), "shades", "tints", "related")
- reverse
logical. If scale should b reversed (default: FALSE)
- ...
arguments to be passed to
discrete_scale
Details
The colorhex
class is a list where there
is a variety of extra information on the hex
colour selected. This information can be used
to create colour scales to be used in ggplot2.
Functions
scale_colour_colorhex_d()
: Discrete colour scalescale_color_colorhex_d()
: Discrete colour scalescale_fill_colorhex_d()
: Discrete fill scalescale_colour_colorhex_c()
: Continuous colour scalescale_color_colorhex_c()
: Continuous colour scalescale_fill_colorhex_c()
: Continuous fill scale
Examples
if(curl::has_internet()){
library(ggplot2)
x <- get_color("#008080")
ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_colorhex_c(x)
ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_colorhex_c(x, "tints")
ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_colorhex_c(x, "shades")
ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_colorhex_d(x, "triadic")
ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_colorhex_d(x, "shades")
}
#> Warning: Removed 32 rows containing missing values (`geom_point()`).