| scale-colorhex | R Documentation | 
Colour and fill scales for ggplot2
plots, using object of class colorhex
as basis for colour choices.
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, ...)
| x | object of class  | 
| 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  | 
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.
a ggplot2-proto
scale_colour_colorhex_d(): Discrete colour scale
scale_color_colorhex_d(): Discrete colour scale
scale_fill_colorhex_d(): Discrete fill scale
scale_colour_colorhex_c(): Continuous colour scale
scale_color_colorhex_c(): Continuous colour scale
scale_fill_colorhex_c(): Continuous fill scale
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")
 }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.