a toolbox for manipulating and assessing color palettes · 50 100 150 0-360-180 0 180 360 hue...

47
A Toolbox for Manipulating and Assessing Color Palettes Achim Zeileis, Jason C. Fisher, Kurt Hornik, Ross Ihaka, Claire D. McWhite, Paul Murrell, Reto Stauffer, Claus O. Wilke http://colorspace.R-Forge.R-project.org/

Upload: others

Post on 29-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

A Toolbox for Manipulating and Assessing Color Palettes

Achim Zeileis, Jason C. Fisher, Kurt Hornik, Ross Ihaka, Claire D. McWhite, Paul Murrell,

Reto Stauffer, Claus O. Wilke

http://colorspace.R-Forge.R-project.org/

Page 2: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency. Grayscale. Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 3: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency.

Grayscale. Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 4: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency. Grayscale.

Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 5: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency. Grayscale. Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 6: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency. Grayscale. Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 7: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency. Grayscale. Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 8: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Map: Influenza severity in Ger-many (week 8, 2019).

Source: ArbeitsgemeinschaftInfluenza, Robert-Koch-Institut.

Reported in: SPIEGEL Online,Tagesschau, . . .

Problems: Color vision defi-ciency. Grayscale. Flashy.

Alternative: HCL-based se-quential palette.

1/27

Page 9: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Need tools for:• Construction of palettes with better perceptual properties.• Assessment of color palettes.• Manipulation of colors.

Because Bob Ross would notapprove of this!

2/27

Page 10: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Motivation

Need tools for:• Construction of palettes with better perceptual properties.• Assessment of color palettes.• Manipulation of colors.

Because Bob Ross would notapprove of this!

2/27

Page 11: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color spaces

Origin of the package: Convert colors between various three-dimensionalrepresentations of color.

In particular: From the perceptually-based HCL (Hue-Chroma-Luminance) tostandard Red-Green-Blue (sRGB, and corresponding hex codes) space.

polarLAB

polarLUV(= HCL)

LAB

LUV

XYZ RGB

HLS

HSV

sRGB hex

white point= D65

gamma(= 2.4)

3/27

Page 12: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

HCL vs. RGB

HCL: Polar coordinates in CIELUV.Captures perceptual dimensions ofthe human visual system very well.

Hue(Type of color)

Chroma(Colorfulness)

Luminance(Brightness)

RGB: Motivated by how comput-ers/TVs used to generate and still rep-resent color.

Red

Green

Blue

4/27

Page 13: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

HCL vs. RGB

HCL: Polar coordinates in CIELUV.Captures perceptual dimensions ofthe human visual system very well.

Hue(Type of color)

Chroma(Colorfulness)

Luminance(Brightness)

RGB: Motivated by how comput-ers/TVs used to generate and still rep-resent color.

Red

Green

Blue

4/27

Page 14: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

HCL vs. RGB: The End of the Rainbow0.

00.

20.

40.

60.

81.

0

Index

0

Red Green Blue

RGB Spectrum

Red

/ G

reen

/ B

lue

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

0.0

0.2

0.4

0.6

0.8

1.0

Index

0

Red Green Blue

RGB Spectrum

Red

/ G

reen

/ B

lue

050

100

150

0

−36

0−

180

018

036

0

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

5/27

Page 15: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

HCL vs. RGB: The End of the Rainbow0.

00.

20.

40.

60.

81.

0

Index

0

Red Green Blue

RGB Spectrum

Red

/ G

reen

/ B

lue

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

0.0

0.2

0.4

0.6

0.8

1.0

Index

0

Red Green Blue

RGB Spectrum

Red

/ G

reen

/ B

lue

050

100

150

0

−36

0−

180

018

036

0

Hue Chroma Luminance

HCL SpectrumC

hrom

a / L

umin

ance

Hue

5/27

Page 16: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Qualitative (Set 2)

Color

Desaturated

Sequential (Blues 3)

Color

Desaturated

Diverging (Green−Brown)

Color

Desaturated

Qualitative: For categorical information, i.e., where no particular ordering ofcategories is available. Function: qualitative_hcl().

Sequential: For ordered/numeric information, i.e., where colors go from high tolow (or vice versa). Function: sequential_hcl().

Diverging: For ordered/numeric information around a central neutral value, i.e.,where colors diverge from neutral to two extremes. Function: diverging_hcl().

6/27

Page 17: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Qualitative (Set 2)

Color

Desaturated

Sequential (Blues 3)

Color

Desaturated

Diverging (Green−Brown)

Color

Desaturated

Qualitative: For categorical information, i.e., where no particular ordering ofcategories is available. Function: qualitative_hcl().

Sequential: For ordered/numeric information, i.e., where colors go from high tolow (or vice versa). Function: sequential_hcl().

Diverging: For ordered/numeric information around a central neutral value, i.e.,where colors diverge from neutral to two extremes. Function: diverging_hcl().

6/27

Page 18: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Qualitative (Set 2)

Color

Desaturated

Sequential (Blues 3)

Color

Desaturated

Diverging (Green−Brown)

Color

Desaturated

Qualitative: For categorical information, i.e., where no particular ordering ofcategories is available. Function: qualitative_hcl().

Sequential: For ordered/numeric information, i.e., where colors go from high tolow (or vice versa). Function: sequential_hcl().

Diverging: For ordered/numeric information around a central neutral value, i.e.,where colors diverge from neutral to two extremes. Function: diverging_hcl().

6/27

Page 19: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Qualitative (Set 2)

Color

Desaturated

Sequential (Blues 3)

Color

Desaturated

Diverging (Green−Brown)

Color

Desaturated

Qualitative: For categorical information, i.e., where no particular ordering ofcategories is available. Function: qualitative_hcl().

Sequential: For ordered/numeric information, i.e., where colors go from high tolow (or vice versa). Function: sequential_hcl().

Diverging: For ordered/numeric information around a central neutral value, i.e.,where colors diverge from neutral to two extremes. Function: diverging_hcl().

6/27

Page 20: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Sequential: Luminance contrast is crucial (dark to light or vice versa).

Blues 2

Blues 3

Blues

7/27

Page 21: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Blues 2: Single hue. Decreasing chroma with increasing luminance.

Blues 2

Blues 3

Blues

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL SpectrumC

hrom

a / L

umin

ance

Hue

7/27

Page 22: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Blues 3: Single hue. Triangular chroma to achieve higher luminance contrast.

Blues 2

Blues 3

Blues

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL SpectrumC

hrom

a / L

umin

ance

Hue

7/27

Page 23: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Blues: Multi hue. Triangular chroma. High luminance contrast.

Blues 2

Blues 3

Blues

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL SpectrumC

hrom

a / L

umin

ance

Hue

7/27

Page 24: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Diverging: Combine two sequential palettes with balanced chroma/luminance.0

2040

6080

100

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

8/27

Page 25: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

Diverging: Combine two sequential palettes with balanced chroma/luminance.0

2040

6080

100

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL SpectrumC

hrom

a / L

umin

ance

Hue

8/27

Page 26: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color palettes: Somewhere over the Rainbow

R> hcl_palettes(plot = TRUE)

Qualitative

Pastel 1

Dark 2

Dark 3

Set 2

Set 3

Warm

Cold

Harmonic

Dynamic

Sequential (single−hue)

Grays

Light Grays

Blues 2

Blues 3

Purples 2

Purples 3

Reds 2

Reds 3

Greens 2

Greens 3

Oslo

Sequential (multi−hue)

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

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

Diverging

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

9/27

Page 27: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Statistical graphics

Base:

• HCL palette functions return hex color vector.

• Typically passed to col = argument of base plotting functions.

ggplot2:

• Scales of type scale_<aesthetic>_<datatype>_<colorscale>().

• <aesthetic> is fill or color/colour.

• <datatype> is discrete or continuous.

• <colorscale> is qualitative, sequential, diverging, or divergingx.

10/27

Page 28: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Statistical graphics: Base

R> q4 <- qualitative_hcl(4, palette = "Dark 3")R> plot(log(EuStockMarkets), plot.type = "single", col = q4, lwd = 2)R> legend("topleft", colnames(EuStockMarkets), col = q4, lwd = 3, bty = "n")

Time

log(

EuS

tock

Mar

kets

)

1992 1993 1994 1995 1996 1997 1998

7.5

8.0

8.5

9.0 DAX

SMICACFTSE

11/27

Page 29: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Statistical graphics: Base

R> ttnc <- margin.table(Titanic, c(1, 4))[, 2:1]R> spineplot(ttnc, col = sequential_hcl(2, palette = "Purples 3"))

Class

Sur

vive

d

1st 2nd 3rd Crew

Yes

No

0.0

0.2

0.4

0.6

0.8

1.0

12/27

Page 30: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Statistical graphics: ggplot2

R> library("ggplot2")R> ggplot(iris, aes(x = Sepal.Length, fill = Species)) + geom_density(alpha = 0.6) ++ scale_fill_discrete_qualitative(palette = "Dark 3")

0.0

0.4

0.8

1.2

5 6 7 8

Sepal.Length

dens

ity

Species

setosa

versicolor

virginica

13/27

Page 31: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Statistical graphics: ggplot2

R> dsamp <- diamonds[1 + 1:1000 * 50, ]R> ggplot(dsamp, aes(carat, price, color = cut)) + geom_point() ++ scale_color_discrete_sequential(palette = "Purples 3", nmax = 6, order = 2:6)

●●●● ●●

●● ●●●● ● ●●●● ●

● ● ●●● ●

● ●●● ●●● ●● ●● ●

●● ● ●●●● ●● ● ●●

● ●● ●●●

● ●● ● ●●

●●●● ● ●● ●●●●●

●● ●● ●●

●●● ●●● ●●● ●●●

●● ● ●●● ●●● ● ●●

●● ●●● ●

●● ●● ●● ●● ● ●●●

●●●● ●●

●● ●●●●

●● ●●● ●●●● ●● ●

●●● ●● ●●● ●●● ●

●● ● ● ●●

● ●●● ●● ●● ●●● ●

●●● ●● ●

● ●●●●●

●● ●●●● ●●●● ● ●

● ● ● ● ●● ●● ●●●●

● ●● ●●●

●● ●● ●● ●●● ●● ●

●● ●●●● ●● ●●●●

●●

●● ●● ●●●●●● ●●

● ●●●● ●● ● ●● ●●

● ●● ●● ●

●● ●● ●●● ●● ●● ●

● ● ●● ● ●●● ●●●●

●●●●●●

●●● ●●●

● ●●●● ●●● ●● ●●

●● ●● ●●

●● ●● ●● ● ●●●● ●

● ● ● ●●● ●● ●●●●

●●● ●●●

● ●●●● ●

● ●● ●●●●● ●●● ●

● ● ●●●●

● ● ●● ● ●● ●●● ●●

●● ● ●● ● ●●●●● ●

● ●● ●●●

●●● ●●● ● ●● ● ●●

● ● ●● ●●

●● ●● ● ●

● ● ●● ●●●● ●●● ●

● ●●● ●● ●●●● ●●

●●●● ●●

●● ●●●●● ●●● ● ●

● ●●● ●●

●●●●●●

● ●●● ●●●● ● ●● ●

●● ●● ●●●●●● ●●

●●● ● ●●●●●●● ●●

●● ●● ●●●

●● ●●●● ●●●●●●●

●●●●● ●● ● ●● ●●●

●● ● ●● ●●

●●●● ●● ●●●● ●●●

●● ●●●●●● ●● ●●●

●● ● ●●● ●●● ●● ●●

●●● ●●● ●● ●●●● ●

●●● ●●●

●● ●●● ●● ●●● ●●

● ●●●● ●

●●●● ●●

●●● ●●●●●●●●●

●● ●●● ●● ●●● ●●

●●●● ● ●

●● ●●● ● ●● ●● ●●

●●● ●● ●●●● ●● ●

● ●

●●● ●●● ●●●● ●●

● ●●● ●●● ●● ●●●

●●● ●● ●

●●●● ● ●● ●● ●● ●

●●● ● ●●●● ●● ●●

● ●●● ●●

●● ●● ●●

●● ●● ●● ●● ● ● ●●

● ●●●● ●

●●● ●●● ●● ●● ●●

●●● ●●

●●●

● ●●●●● ●● ● ●●●

●●● ●●● ● ●●●●●

●●● ●●●

● ●● ●● ●●●●● ●●

●● ●●● ●● ●● ●●●

●●● ●● ●

● ●● ●●●

●● ● ●●●● ●●●● ●

● ●● ●● ●

●● ●● ●● ●●● ● ●●

●● ●●●● ●●● ●●●

0

5000

10000

15000

1 2 3

carat

pric

e

cut

Fair

Good

Very Good

Premium

Ideal

14/27

Page 32: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Visualization and assessment

Visualizations: Based on vector of colors.

• swatchplot(): Color swatches.

• specplot(): Spectrum of HCL and/or RGB trajectories.

• hclplot(): Trajectories in 2-dimensional HCL space projections.

• demoplot(): Illustrations of typical (and simplified) statistical graphics.

15/27

Page 33: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Visualization and assessment: hclplot()

R> hclplot(qualitative_hcl(7, palette = "Set 2"))R> hclplot( sequential_hcl(7, palette = "Blues 3"))R> hclplot( diverging_hcl(7, palette = "Blue-Red"))

16/27

Page 34: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Visualization and assessment: demoplot()

R> cl <- sequential_hcl(5, palette = "Heat")R> demoplot(cl, type = "...")

map heatmap

●●

● ●

●●●●

●●●

●● ●

●●●

● ●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●● ●

●●

●●●

● ●●●

●●

●●

● ●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●●

●●

●●●

●●

●●

●●●

● ●

●●

●●

●●

●●● ●

●●●

●●

●●

●●

●●

●●

●● ●●

●●

●●●●●

●●

●● ●●

● ●

●●

●● ●

● ●

●●●●

● ●

●●●●

●●

●●●

●●●●

●● ●

●●

● ●●●

●●

●●

●●

● ●●

● ●

●● ●●

●●

●●●

●●● ●●

●●

●● ●●

● ● ●●

●●

●●●

●●

●●●

●● ●

●●●

●●

●●

●●

●●●

● ●

●●

●● ●

●●

●● ●●●

●●

●●●

●●● ●

●●●

●●●●

● ●● ●

●● ●

●●● ●

●● ●

●●

●●

●●●

● ●●●

●●

●●

●●

scatter spine bar

pie perspective mosaic lines

17/27

Page 35: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color vision deficiency

Emulate: Color vision deficiencies.• deutan(): Deuteranopia (green deficient).• protan(): Protanopia (red deficient).• tritan(): Tritanopia (blue deficient).

Example: Maunga Whau volcano data.

18/27

Page 36: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color vision deficiency

rainbow(11, end = 2/3)

Original Desaturated Deuteranope

sequential_hcl(11, "Blue−Yellow")

19/27

Page 37: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Approximations of other palettes

ColorBrewer.org: YlGnBu0

2040

6080

100

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

Viridis

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

20/27

Page 38: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Approximations of other palettes

ColorBrewer.org: YlGnBu0

2040

6080

100

0

090

180

270

360

Hue Chroma Luminance

HCL Spectrum

Chr

oma

/ Lum

inan

ce

Hue

Viridis

020

4060

8010

0

0

090

180

270

360

Hue Chroma Luminance

HCL SpectrumC

hrom

a / L

umin

ance

Hue

20/27

Page 39: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color apps

Facilitate exploration: Graphical user interfaces as shiny apps.

• Palette constructor: choose_palette() or hclwizard() (also in tcltk).

• Color picker: choose_color() or hcl_color_picker().

• Color vision deficiency emulator: cvd_emulator().

Online versions: http://hclwizard.org/

21/27

Page 40: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color apps: choose_palette() / hclwizard()

22/27

Page 41: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color apps: choose_color() / hcl_color_picker()

23/27

Page 42: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Color apps: cvd_emulator()

24/27

Page 43: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Base R

In 3.6.0: All prespecified palettes also via grDevices::hcl.colors().

Pastel 1

Dark 2

Dark 3

Set 2

Set 3

Warm

Cold

Harmonic

Dynamic

Grays

Light Grays

Blues 2

Blues 3

Purples 2

Purples 3

Reds 2

Reds 3

Greens 2

Greens 3

Oslo

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

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

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

ArmyRose

Earth

Fall

Geyser

TealRose

Temps

PuOr

RdBu

RdGy

PiYG

PRGn

BrBG

RdYlBu

RdYlGn

Spectral

Zissou 1

Cividis

25/27

Page 44: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Base R: Why you might not need our package after all

In 3.6.0: All prespecified palettes also via grDevices::hcl.colors().

Pastel 1

Dark 2

Dark 3

Set 2

Set 3

Warm

Cold

Harmonic

Dynamic

Grays

Light Grays

Blues 2

Blues 3

Purples 2

Purples 3

Reds 2

Reds 3

Greens 2

Greens 3

Oslo

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

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

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

ArmyRose

Earth

Fall

Geyser

TealRose

Temps

PuOr

RdBu

RdGy

PiYG

PRGn

BrBG

RdYlBu

RdYlGn

Spectral

Zissou 1

Cividis

25/27

Page 45: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Recommendations

Colors and palettes:

• Do not overestimate the effectiveness of color.

• Choose type of palette based on the data to be visualized.

• For areas use light colors (higher luminance, lower chroma).

• For points/lines darker colors are needed (lower luminance, higher chroma).

• For palettes with more colors stronger luminance contrasts are needed.

• Triangular chroma trajectories useful for distinguishing central colors.

R packages:

• colorspace facilitates exploration, manipulation, and assessment.

• HCL approximations of palettes from RColorBrewer, rcartocolor, scico, . . .

• Prespecified palettes are also easily available in base R.

26/27

Page 46: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

Recommendations

Colors and palettes:

• Do not overestimate the effectiveness of color.

• Choose type of palette based on the data to be visualized.

• For areas use light colors (higher luminance, lower chroma).

• For points/lines darker colors are needed (lower luminance, higher chroma).

• For palettes with more colors stronger luminance contrasts are needed.

• Triangular chroma trajectories useful for distinguishing central colors.

R packages:

• colorspace facilitates exploration, manipulation, and assessment.

• HCL approximations of palettes from RColorBrewer, rcartocolor, scico, . . .

• Prespecified palettes are also easily available in base R.

26/27

Page 47: A Toolbox for Manipulating and Assessing Color Palettes · 50 100 150 0-360-180 0 180 360 Hue Chroma Luminance HCL Spectrum Chroma / Luminance Hue 5/27. Color palettes: Somewhere

References

Zeileis A, Fisher JC, Hornik K, Ihaka R, McWhite CD, Murrell P, Stauffer R, Wilke CO(2019). “colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes.”arXiv:1903.06490, arXiv.org E-Print Archive. http://arxiv.org/abs/1903.06490

Zeileis A, Hornik K, Murrell P (2009). “Escaping RGBland: Selecting Colors for StatisticalGraphics.” Computational Statistics & Data Analysis, 53, 3259–3270.doi:10.1016/j.csda.2008.11.033.

Stauffer R, Mayr GJ, Dabernig M, Zeileis A (2015). “Somewhere over the Rainbow: Howto Make Effective Use of Colors in Meteorological Visualizations.” Bulletin of theAmerican Meteorological Society, 96(2), 203–216. doi:10.1175/BAMS-D-13-00155.1

27/27