scale-colorhex: Colour scales for ggplot2

scale-colorhexR Documentation

Colour scales for ggplot2

Description

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.

Value

a ggplot2-proto

Functions

  • 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

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")
 }

colorhex documentation built on Sept. 11, 2023, 9:06 a.m.