Create a lattice theme based on specified colors

Description

Creates a lattice theme given a few colors. Non-color settings are not included. The colors are typically used to define the standard grouping (superposition) colors, and the first color is used for ungrouped displays.

Usage

1
2
3
4
5
6
7
8
custom.theme(symbol = brewer.pal(n = 8, name = "Dark2"),
             fill = brewer.pal(n = 12, name = "Set3"),
             region = brewer.pal(n = 11, name = "Spectral"),
             reference = "#e8e8e8",
             bg = "transparent", fg = "black", ...)

## different defaults ("Set1", "Accent", "RdBu"):
custom.theme.2(...)

Arguments

symbol

a vector of symbol colors.

fill

a vector of fill colors (for barcharts, etc.)

region

a vector of colors that is used to define a continuous color gradient using colorRampPalette

reference

a color for reference lines and such

bg

a background color

fg

a foreground color, primarily for annotation

...

further arguments passed to simpleTheme and used to modify the theme.

Value

A list that can be supplied to trellis.par.get or as the theme argument to trellis.device.

Author(s)

Deepayan Sarkar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
set.seed(0)

## create a plot to demonstrate graphical settings
obj <-
xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width, iris,
       type = c("p", "r"), jitter.x = TRUE, jitter.y = TRUE, factor = 5,
       auto.key = list(lines = TRUE, rectangles = TRUE))
obj <- update(obj, legend = list(right =
         list(fun = "draw.colorkey", args = list(list(at = 0:100)))))


## draw with default theme
obj

## draw with custom.theme()
update(obj, par.settings = custom.theme())

## create a theme with paired colours, filled points, etc
update(obj, par.settings =
  custom.theme(symbol = brewer.pal(12, "Paired"),
               fill = brewer.pal(12, "Paired"),
               region = brewer.pal(9, "Blues"),
               bg = "grey90", fg = "grey20", pch = 16))

## draw with custom.theme.2()
update(obj, par.settings = custom.theme.2())

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.