map Function (GPL)

Syntax

map((<value>, <aesthetic>) ...)

<value>. A categorical value that is being mapped to a specific aesthetic.

<aesthetic>. A valid aesthetic value or constant (for example, color.red or size."5px") that will be used for the categorical value.

Note: A value and aesthetic pair is enclosed in parentheses. If you are specifying multiple pairs, use commas to separate the pairs.

Description

Maps a specific categorical value to a specific aesthetic value. For example, if you were creating a bar chart showing the median income in each U.S. state, you could use the map function to force the color of the bar corresponding to Illinois to be blue.

Examples

Figure 1. Example: Mapping a category to a color
SCALE: cat(aesthetic(aesthetic.color), map(("IL", color.blue)))
Figure 2. Example: Mapping multiple categories to colors
SCALE: cat(aesthetic(aesthetic.color), map(("IL", color.blue), ("CA", color.green)))