On 2011-03-10 15:07, Jim Price wrote:> Hi,
>
> I'm currently designing some global themes for use with lattice, and
have
> hit a snag. There doesn't appear to be (in xyplot at least) a way of
setting
> a lattice option for the 'scales' parameter at a global level -
changes have
> to be made in each function call. For example, consider the following code:
>
> library(lattice)
> library(latticeExtra)
>
> # Create some data
> temp<- expand.grid(
> subject = paste('Subject', 1:2),
> var = paste('Variable', 1:2),
> time = 1:10)
> temp$resp<- rnorm(nrow(temp))
>
> # Example 1 - this is what I want to get to
> useOuterStrips(xyplot(
> resp ~ time | subject * var,
> data = temp,
> as.table = TRUE,
> between = list(x = 0.2, y = 0.2),
> scales = list(alternating = 1, tck = c(1, 0), col =
'black')
> ))
>
> # Example 2 - set up theme for later use
> my.opts<- list(default.args = list(
> as.table = TRUE,
> between = list(x = 0.2, y = 0.2),
> scales = list(alternating = 1, tck = c(1, 0), col =
'black') #
> Illustrative, doesn't do anything
> ))
>
> dev.new()
> useOuterStrips(xyplot(
> resp ~ time | subject * var,
> data = temp,
> lattice.options = my.opts # Note that the scales don't
propagate
> ))
>
>
> As you can see the as.table and between parameters filter down nicely, but
> the scales don't. This looks like this is intended by the current code
- the
> defaults in xyplot.formula for both scales and default.scales are empty
> lists - so I don't know if this is: intended for some technical reason
> that's just not obvious to me; an oversight on my part and there's
some
> other way of doing this; or a feature that could be added.
New feature not needed. You'll notice that the 'Details'
section of ?xyplot says, regarding lattice.options:
Default values can be set in this manner for the following
arguments: as.table, aspect, between, page, main, sub,
par.strip.text, layout, skip and strip.
No mention of 'scales'. But xyplot has an argument
'default.scales' which you can set globally:
def.scal <- list(alternating = 1, tck = c(1, 0))
and then add this
default.scales = def.scal
to the arguments in your xyplot call.
Peter Ehlers
>
> Of course, I could also take this as a chance to learn how to submit
> patches, but thought I'd check to see if I'm missing anything
first.
>
> Technical stuff (because I'm not completely up to date):
>
>> sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
> States.1252 LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C LC_TIME=English_United
> States.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] latticeExtra_0.6-14 RColorBrewer_1.0-2 lattice_0.19-13
>
> loaded via a namespace (and not attached):
> [1] grid_2.12.0
>
>
> Jim Price.
> Cardiome Pharma. Corp.
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Lattice-Feature-Request-tp3347040p3347040.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.