Learn R Programming

cartography (version 2.2.1)

carto.pal: Build Cartographic Palettes

Description

Build sequential, diverging and qualitative color palettes. Diverging color palettes can be dissymmetric (different number of colors in each of the two gradients).

Usage

carto.pal(pal1, n1, pal2 = NULL, n2 = NULL, middle = FALSE,
  transparency = FALSE)

Arguments

pal1

name of the color gradient (see Details).

n1

number of colors (up to 20).

pal2

name of the color gradient (see Details).

n2

number of colors (up to 20).

middle

a logical value. If TRUE, a neutral color ("#F6F6F6", light grey) between two gradients is added.

transparency

a logical value. If TRUE, contrasts are enhanced by adding an opacity variation.

Value

A vector of colors is returned.

Details

Sequential palettes:

  • blue.pal

  • orange.pal

  • red.pal

  • brown.pal

  • green.pal

  • purple.pal

  • pink.pal

  • wine.pal

  • grey.pal

  • turquoise.pal

  • sand.pal

  • taupe.pal

  • kaki.pal

  • harmo.pal

Qualitative palettes:

  • pastel.pal

  • multi.pal

References

Qualitative palettes were generated with "i want hue" (http://tools.medialab.sciences-po.fr/iwanthue/) by Mathieu Jacomy at the Sciences-Po Medialab.

See Also

display.carto.pal, display.carto.all, carto.pal.info

Examples

Run this code
# NOT RUN {
# Simple gradient: blue
carto.pal(pal1 = "blue.pal" ,n1 = 20)

# Double gradient: blue & red
carto.pal(pal1 = "blue.pal", n1 = 10, pal2 = "red.pal", n2 = 10)

# Adding a neutral color
carto.pal(pal1 = "blue.pal", n1 = 10, pal2 = "red.pal", n2 = 10, middle = TRUE)

# Enhancing contrasts with transparency
carto.pal(pal1="blue.pal", n1 = 10, pal2 = "red.pal", n2 = 10, middle = TRUE,
          transparency = TRUE)

# The double gradient can be asymetric
carto.pal(pal1 = "blue.pal", n1 = 5, pal2 = "red.pal", n2 = 15, middle = TRUE,
          transparency = TRUE)

# Build and display a palette
mypal <- carto.pal(pal1 = "blue.pal", n1 = 5, pal2 = "red.pal", n2 = 15,
                   middle = TRUE, transparency = TRUE)
k <- length(mypal)
image(1:k, 1, as.matrix(1:k), col =mypal, xlab = paste(k," classes",sep=""),
      ylab = "", xaxt = "n", yaxt = "n",bty = "n")
# }

Run the code above in your browser using DataLab