custom.theme: Create a lattice theme based on specified colors

Description Usage Arguments Value Author(s) Examples

View source: R/custom.theme.R

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
 9
10
custom.theme(symbol = RColorBrewer::brewer.pal(n = 8, name = "Dark2"),
             fill = RColorBrewer::brewer.pal(n = 12, name = "Set3"),
             region = RColorBrewer::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 = RColorBrewer::brewer.pal(12, "Paired"),
               fill = RColorBrewer::brewer.pal(12, "Paired"),
               region = RColorBrewer::brewer.pal(9, "Blues"),
               bg = "grey90", fg = "grey20", pch = 16))

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

Example output

Loading required package: lattice
Loading required package: RColorBrewer

latticeExtra documentation built on Sept. 19, 2020, 3:01 p.m.