Skip to content

lattice: par.settings with standard.theme() + additional arguments?

6 messages · Marius Hofert, David Winsemius

#
Dear expeRts,

I usually use par.settings = standard.theme(color = FALSE) to create lattice graphics
without colors, so something like

library(lattice)
x <- runif(10)
xyplot(x ~ 1:10, type = "l", par.settings = standard.theme(color = FALSE))

Now I would like to use an additional component in par.settings. I tried several things
like

xyplot(x ~ 1:10, type = "l", par.settings = c(standard.theme(color = FALSE), list(par.xlab.text = list(cex = 5, col = "blue"))))

but it doesn't work. I know I could use lattice.options() but is there a way to get it
right ("locally") with par.settings?

Cheers,

Marius
#
On Jan 4, 2011, at 5:57 AM, Marius Hofert wrote:

            
Add it as a list element:

xyplot(x ~ 1:10, type = "l", par.settings = list(standard.theme(color  
= FALSE), par.xlab.text = list(cex = 5, col = "blue")))
#
Dear David,

this I already tried. But as you can see, the plot itself *is* colored. However, I want to have color = FALSE, so, unfortunately, this approach does not work...

Cheers,

Marius
On 2011-01-04, at 14:32 , David Winsemius wrote:

            
#
On Jan 4, 2011, at 8:39 AM, Marius Hofert wrote:

            
Quite right. I didn't see that until you pointed it out. I had many  
failed attempts at a solution and then searched for prior positngs  
using par.settings and standard.theme and found one by Ehlers earlier  
this year that seems to work when modified to your ends:

xyplot(x ~ 1:10, type = "l", par.settings =  
modifyList(standard.theme(color = FALSE),
       list(par.xlab.text = list(cex = 5) )))

I had tried various constructions that I thought would be equivalent,  
but I think I was getting the levels of the list structure wrong. This  
also works:

xyplot(x ~ 1:10, type = "l", par.setting=c(list(par.xlab.text =  
list(cex = 5), standard.theme(color = FALSE))  )

Notice the use of c() rather than list() to bind them together. When I  
looked at the output of standard.theme(color=FALSE), there was no  
par.xlab.text element so it seemed as though there should be no  
conflict and in fact there wasn't (except for the asynchrony between  
my brain and the R interpreter.)

best;
David.
David Winsemius, MD
West Hartford, CT
#
On Jan 4, 2011, at 11:08 AM, David Winsemius wrote:

            
### NO,  it doesn't. I failed to notice that the command was  
incomplete so was looking at my prior plot.
Proving that I still do not really understand why the modifyList  
approach works and what seemed to be equivalents do not. (Next  
paragraph is wrong.)
David Winsemius, MD
West Hartford, CT
#
Dear David,

that's funny to read. I guess we did pretty much the same. I also thought I got the list structure wrong and I also tried c()... (since I recently learned from Gabor that a list is only a vector of mode list).... and I also searched for posts with exactly the same words [but wasn't as successful as you :-)].

Thanks for the modifyList()-trick!

Cheers,

Marius
On 2011-01-04, at 17:37 , David Winsemius wrote: