例如:
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)
它不起作用。
答案 0 :(得分:4)
主题可以持久设置(即,它们将影响所有后续绘图直到新的
使用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())