3

例如:

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.settingsmytheme


在书Lattice Multivariate Data Visualization with R中,第 131 页,作者给出了这个例子:

lattice.options(lattice.theme = standard.theme("pdf"))

但我不知道如何使其适应当前情况。我试过了:

lattice.options(lattice.theme = mytheme)

它不起作用。

4

1 回答 1

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())
于 2013-10-25T19:48:46.027 回答