【问题标题】:R lattice set default argumentsR lattice 设置默认参数
【发布时间】:2012-04-05 14:24:16
【问题描述】:

我想在 R 包点阵的 levelplot() 中指定一些选项。我设置了参数scales,这很好用:

scales = list(x = list(at = c(0:8*16 +.5),
                   cex = 0), 
          y = list(at = c(0:8*16+.5),
                   cex = 0))    

现在,我想将此参数设为默认值。 IE。我想在会话中的每个levelplot() 中都有这个比例,而不是每次都指定这个参数。我试着用lattice.options() 来做这个,但我不知道怎么做。

【问题讨论】:

  • 一种方法是将此列表存储在一个变量中,并在每次使用 levelplot 时调用此变量。

标签: r set default options lattice


【解决方案1】:

lattice::trellis.par.set() 怎么样?

【讨论】:

    【解决方案2】:

    设置对象是通过 trellis.par.get("name of component to be set") 检索的。例如:

    plot.line.settings <- trellis.par.get("plot.line")
    

    plot.line.settings 对象是列表,其项目可以更改/更新。然后设置全局设置:

    trellis.par.set("plot.line", plot.line.settings)
    

    要使设置适用于任何未来打开的设备,必须在打开设备时将保留参数设置为 TRUE。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-22
      • 2013-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多