Examples for 'colorspace::hcl_palettes'


HCL Color Palettes

Aliases: hcl_palettes print.hcl_palettes summary.hcl_palettes plot.hcl_palettes qualitative_hcl sequential_hcl diverging_hcl diverge_hcl

Keywords: color

### ** Examples

## overview of all _named_ HCL palettes
hcl_palettes()
HCL palettes

Type:  Qualitative 
Names: Pastel 1, Dark 2, Dark 3, Set 2, Set 3, Warm, Cold, Harmonic, Dynamic

Type:  Sequential (single-hue) 
Names: Grays, Light Grays, Blues 2, Blues 3, Purples 2, Purples 3, Reds 2,
       Reds 3, Greens 2, Greens 3, Oslo

Type:  Sequential (multi-hue) 
Names: Purple-Blue, Red-Purple, Red-Blue, Purple-Orange, Purple-Yellow,
       Blue-Yellow, Green-Yellow, Red-Yellow, Heat, Heat 2, Terrain,
       Terrain 2, Viridis, Plasma, Inferno, Rocket, Mako, Dark Mint,
       Mint, BluGrn, Teal, TealGrn, Emrld, BluYl, ag_GrnYl, Peach,
       PinkYl, Burg, BurgYl, RedOr, OrYel, Purp, PurpOr, Sunset,
       Magenta, SunsetDark, ag_Sunset, BrwnYl, YlOrRd, YlOrBr, OrRd,
       Oranges, YlGn, YlGnBu, Reds, RdPu, PuRd, Purples, PuBuGn, PuBu,
       Greens, BuGn, GnBu, BuPu, Blues, Lajolla, Turku, Hawaii, Batlow

Type:  Diverging 
Names: Blue-Red, Blue-Red 2, Blue-Red 3, Red-Green, Purple-Green,
       Purple-Brown, Green-Brown, Blue-Yellow 2, Blue-Yellow 3,
       Green-Orange, Cyan-Magenta, Tropic, Broc, Cork, Vik, Berlin,
       Lisbon, Tofino
## visualize
hcl_palettes("qualitative", plot = TRUE)
plot of chunk example-colorspace-hcl_palettes-1
hcl_palettes("sequential (single-hue)", n = 7, plot = TRUE)
plot of chunk example-colorspace-hcl_palettes-1
hcl_palettes("sequential (multi-hue)", n = 7, plot = TRUE)
plot of chunk example-colorspace-hcl_palettes-1
hcl_palettes("diverging", n = 7, plot = TRUE)
plot of chunk example-colorspace-hcl_palettes-1
## inspect a specific palette
## (upper-case, spaces, etc. are ignored for matching)
hcl_palettes(palette = "Dark 2")
HCL palette
Name: Dark 2
Type: Qualitative
Parameter ranges:
 h1 h2 c1 c2 l1 l2 p1 p2 cmax fixup
  0 NA 50 NA 60 NA NA NA   NA  TRUE
hcl_palettes(palette = "dark2")
HCL palette
Name: Dark 2
Type: Qualitative
Parameter ranges:
 h1 h2 c1 c2 l1 l2 p1 p2 cmax fixup
  0 NA 50 NA 60 NA NA NA   NA  TRUE
## set up actual colors
qualitative_hcl(4, h = c(0, 288), c = 50, l = 60) ## by hand
[1] "#C87A8A" "#8A9748" "#00A2A2" "#A782C3"
qualitative_hcl(4, palette = "dark2")             ## by name
[1] "#C87A8A" "#909646" "#00A396" "#9189C7"
qualitative_hcl(4, palette = "dark2", c = 80)     ## by name plus modification
[1] "#E16A86" "#909800" "#00AD9A" "#9183E6"
## how HCL palettes are constructed:
## by varying the perceptual properties via hue/chroma/luminance
swatchplot(
  "Hue"       = sequential_hcl(5, h = c(0, 300), c = c(60, 60), l = 65),
  "Chroma"    = sequential_hcl(5, h = 0, c = c(100, 0), l = 65, rev = TRUE, power = 1),
  "Luminance" = sequential_hcl(5, h = 260, c = c(25, 25), l = c(25, 90), rev = TRUE, power = 1),
  off = 0
)
plot of chunk example-colorspace-hcl_palettes-1
## for qualitative palettes luminance and chroma are fixed, varying only hue
hclplot(qualitative_hcl(9, c = 50, l = 70))
plot of chunk example-colorspace-hcl_palettes-1
## single-hue sequential palette (h = 260) with linear vs. power-transformed trajectory
hclplot(sequential_hcl(7, h = 260, c = 80, l = c(35, 95), power = 1))
plot of chunk example-colorspace-hcl_palettes-1
hclplot(sequential_hcl(7, h = 260, c = 80, l = c(35, 95), power = 1.5))
plot of chunk example-colorspace-hcl_palettes-1
## advanced single-hue sequential palette with triangular chroma trajectory
## (piecewise linear vs. power-transformed)
hclplot(sequential_hcl(7, h = 245, c = c(40, 75, 0), l = c(30, 95), power = 1))
plot of chunk example-colorspace-hcl_palettes-1
hclplot(sequential_hcl(7, h = 245, c = c(40, 75, 0), l = c(30, 95), power = c(0.8, 1.4)))
plot of chunk example-colorspace-hcl_palettes-1
## multi-hue sequential palette with small hue range and triangular chroma vs.
## large hue range and linear chroma trajectory
hclplot(sequential_hcl(7, h = c(260, 220), c = c(50, 75, 0), l = c(30, 95), power = 1))
plot of chunk example-colorspace-hcl_palettes-1
hclplot(sequential_hcl(7, h = c(260, 60), c = 60, l = c(40, 95), power = 1))
plot of chunk example-colorspace-hcl_palettes-1
## balanced diverging palette constructed from two simple single-hue sequential
## palettes (for hues 260/blue and 0/red)
hclplot(diverging_hcl(7, h = c(260, 0), c = 80, l = c(35, 95), power = 1))
plot of chunk example-colorspace-hcl_palettes-1
## to register a particular adapted palette for re-use in the same session
## with a new name the register=... argument can be used once, e.g.,
diverging_hcl(7, palette = "Tropic", h2 = 0, register = "mytropic")

## subsequently palete="mytropic" is available in diverging_hcl() and the diverging
## ggplot2 scales such as scale_color_continuous_diverging() etc.
demoplot(diverging_hcl(11, "mytropic"), type = "map")
plot of chunk example-colorspace-hcl_palettes-1
## to register this palette in all R sessions you could place the following
## code in a startup script (e.g., .Rprofile):
## colorspace::diverging_hcl(7, palette = "Tropic", h2 = 0, register = "mytropic")

[Package colorspace version 2.0-3 Index]