unipalette: A 7 category qualitative palette

Description Usage Arguments Value Base palette, in default ordering Palette characteristics Palette ordering Palette subsets Examples

View source: R/unipalette.R

Description

unipalette() produces qualitative palettes based on a preset 7-color palette optimized for lines, points, bars, etc, on a white background.

Usage

1
unipalette(colors = NULL, order = "difference")

Arguments

colors

Integer vector or character vector. colors=4 returns the first 4 colors of the default ordering. colors=2:5 returns the colors 2 through 5 of the default ordering. colors=c("red","lightblue","purple") returns the named colors in the order given.

order

Character. "difference", "lightness", or "hybrid". The ordering for the palette (see details).

Value

character vector. A vector of named RGB colors specified as hex color codes (#RRGGBB).

Base palette, in default ordering

#'

red lightblue black green purple pink blue
"#a11c3e""#5798d1""#252525""#319045""#5e2b7b""#e2908c""#226e83"

Palette characteristics

The default ordering (order="difference") maximizes differences in hue and lightness between adjacent colors. This aids discrimination of data plotted side by side, and also helps avoid implications that the data is ordinal.

Palette ordering

Two alternate orderings are also provided.

Palette subsets

unipalette(4) returns the first 4 colors of the default ordering. unipalette(2:5) returns the colors 2 through 5 of the default ordering. unipalette(c("red","lightblue","purple")) returns the named colors in the order given.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 3 orderings:
difference <- unipalette(); colorbar(difference,dots=TRUE)
lightness <- unipalette(order="lightness"); colorbar(lightness,dots=TRUE)
hybrid <- unipalette(order="hybrid"); colorbar(hybrid,dots=TRUE)

## subsets
subset <- unipalette(4); colorbar(subset,dots=TRUE)

## Sample plot
randomseries <- data.frame(x=1:4, y=runif(4*7), grp=rep(letters[1:7],each=4))
pal <- unipalette()
lattice::xyplot(y~x, group=grp, data=randomseries, type="b", pch=16, lwd=3, col = pal,
       key = list(space = "right", text=list(letters[1:7], lines = list(col=pal, lwd=3)))
       )

allopole/datacolor documentation built on May 4, 2019, 6:39 p.m.