例如:
mytheme <- trellis.par.get()
mytheme$strip.border$col = 'grey80'
mytheme$strip.background$col = 'grey80'
mytheme$axis.line$col = 'grey80'
mytheme$axis.text$col = 'grey60'
mytheme$plot.symbol$pch = 20
mytheme$plot.symbol$cex = .5
mytheme$plot.symbol$col = '#7AC5CD'
mytheme$plot.symbol$alpha = .8
l.sc <- update(scatter.lattice, par.settings = mytheme,
layout = c(3, 2),
between = list(x = 0.3, y = 0.3))
print(l.sc)
如何将par.settings
的默认值设置为mytheme
?
在《Lattice Multivariate Data Visualization with R》一书中,第131页,作者给出了这样一个例子:
lattice.options(lattice.theme = standard.theme("pdf"))
但我看不出如何使其适应当前的情况。我试过了:
lattice.options(lattice.theme = mytheme)
而且它不起作用。
主题可以永久设置(即,它们将影响所有后续情节,直到新的设置指定)使用 trellis.par.set()
函数:
trellis.par.set(mytheme) ## mythme is a named list with settings parameters
其中mytheme是一个列表(不需要调用trellis.par.get()):
mytheme <- list()
mytheme$strip.border$col = 'grey80'
mytheme$strip.background$col = 'grey80'
mytheme$axis.line$col = 'grey80'
mytheme$axis.text$col = 'grey60'
mytheme$plot.symbol$pch = 20
mytheme$plot.symbol$cex = .5
mytheme$plot.symbol$col = '#7AC5CD'
mytheme$plot.symbol$alpha = .8
要临时设置主题,您可以设置格子的"par.settings"参数绘图功能。例如,这是latticeExtra
设置 ggplot2 类似主题的方式:
library(latticeExtra)
xyplot(exp(1:10) ~ 1:10, type = "b",
par.settings = ggplot2like())