Learn R Programming

duke (version 0.0.3)

scale_duke_continuous: Continuous scale constructor.

Description

Applies a Duke branded and accessible continuous color scale to ggplot geometric objects. It is applicable for both fill and color arguments. Defines gradient scale from dark to light to improve visibility and contrast for readers.

Usage

scale_duke_continuous(
  ...,
  low = "#00539B",
  high = "#E2E6ED",
  space = "Lab",
  na.value = "#666666",
  guide = "colourbar",
  aesthetics = c("colour", "color", "fill")
)

Value

a visualization with continuous duke color scale

Arguments

...

Arguments passed on to continuous_scale().

low

Low end of color gradient.

high

High end of color gradient.

space

Color space in which to calculate gradient.

na.value

Color used for NA values.

guide

Type of legend. "colorbar" for continuous scale, "legend" for discrete scale.

aesthetics

String or vector of strings detailing what aesthetic features this continuous scale can apply to.

Examples

Run this code
library(ggplot2)
library(palmerpenguins)

# default
ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, color = body_mass_g)) +
  geom_point()

# vs. with Duke scale
ggplot(penguins, aes(x = bill_depth_mm, y = bill_length_mm, color = body_mass_g)) +
  geom_point() +
  scale_duke_continuous()

Run the code above in your browser using DataLab