td: Set lattice parameters for multiple groups

Description Usage Arguments Details Functions Author(s) Examples

Description

Easier alternative to using trellis.par.set and trellis.par.get to change lattice colors, line types, etc.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
td(new = FALSE, col = c("#0080ff", "#ff00ff", "darkgreen", "#ff0000",
  "orange", "#00ff00", "brown"), lty = 1:7, lwd = 1, pch = 1:7,
  cex = 0.8, font = 1, long = FALSE, basecol = NULL,
  colsets = c("plot.symbol", "plot.line", "dot.symbol", "dot.line",
  "cloud.3d", "box.dot"), ...)

gd(n = 9, col = brewer.pal(n, "Set1"), lty = 1:n, lwd = 1, pch = 19,
  cex = 1.4, font = 1, fill = "transparent", col.line = col,
  col.symbol = col, alpha = 1, alpha.line = alpha, alpha.symbol = alpha,
  len = n, h = c(0, 360) + 15, l = 65, c = 100, h.start = 0,
  direction = 1, low = "#3B4FB8", high = "#B71B1A", space = "rgb",
  basecol = NULL, colsets = c("plot.symbol", "plot.line", "dot.symbol",
  "dot.line", "cloud.3d", "box.dot"), superpose = TRUE, gginit = FALSE, ...)

gd_(...)

Arguments

new

If new = TRUE, open a new window, otherwise modify the existing active window, if there is one.

cex

for each level of the groups variable

long

if TRUE generate a default combination of col, lty and pch with length 42.

n

in 'gd' specifies the number of distinct colours to generate to distinguish groups. 'gd' uses 'latticeExtra' to set defaults for a ggplot2-like appearance. Default is n = 4

col.line

not given

col.symbol

'groups' not given

alpha.symbol

graphical parameters for superpose.line and superpose.symbol

len

extend the length of parameters by recycling to length 'len'

record

If TRUE, set history to 'recording'. Caution: this can use a lot of memory in .GlobalEnv. Consider adding selected graphs to memory with the 'Insert' key instead.

...

parameter: e.g. plot.symbol=list(cex=2,col='red'). Particular useful for the cex, col, lty, lwd, alpha, pch parameters in plot.line and plot.symbol.

n

number of groups for which to set colors, line types, etc. using RColorBrewer.

Details

Designed to easily set lattice parameters for multiple groups. Setting parameters before calling the lattice function allows parameters to be used consistently in the group key.

'td' calls 'trellis.device' and sets graphical parameters for 'superpose.line' and 'superpose.symbol'. 'td' also initializes a new trellis device with a white background if new = TRUE.

'gd' is similar to 'td' except that it uses a theme that resembles that of 'ggplot'

Functions

Author(s)

Georges Monette

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
27
28
29
30
31
32
33
34
td( lty = 1:7)   # sets line types for 7 groups
gd(7)            # sets line types for 7 groups using colors from RColorBrewer
td( plot.symbol = list(col = 'red', pch = 17))
gd_(col='blue')  # set main color to 'blue'
#   - setting colors for groups, i.e. 'superpose.symbol' in trellis.par.get():
gd(5)  # where 5 is the number of groups
gd(5, lwd = 2, lty = 1)
gd(5, col = brewer.pal(5,"Dark2"),cex = 1.5)

# To set colors with no groups
gd_(col='tomato4')
# changing the default color for lines and symbols
gd(plot.line=list(col='red',lwd=2),
           plot.symbol=list(col='blue', cex = 1.3))
# OR using superpose = FALSE
gd(superpose = FALSE, col = 'red', lwd = 2)
# OR using the utility function:
gd_(col = 'red', lwd = 2)
#
#  For a complete list of elements that can be changed:
names(trellis.par.get())
# For a list of colors
colors()
grepv('pink',colors()) # types of pink
# Using magrittr
library(magrittr)
colors()  %>%  grepv('blue', .)  %>%
  pal  %>%
  as.data.frame %>%
  sortdf( ~ red)  %>%
  as.matrix  %>%
  divide_by(255)  %>%
  rgb  %>%
  pal

gmonette/yscs documentation built on May 17, 2019, 7:28 a.m.