Skip to content

Controlling graphics parameters in lattice

3 messages · Michael Friendly, Brian Ripley, Deepayan Sarkar

#
I'm just starting to work with lattice graphics, and am
having difficulty understanding how to control various graphic
parameters (font sizes, etc.).  [I'm actually using xyplot
via plot.effect() in the car package, and would like to be
able to set some global defaults.]

I read ?xyplot and ?trellis.par.set-- which contains no complete
list of parameters, just a reference to print(trellis.par.get())
$fontsize
$fontsize$default
[1] 10

I tried
And this crashes the Rgui (Windows, R 1.6.1).  Is this a buglet
or did I do something wrong?

I then tried
which makes the tick labels larger, but not the axis labels.

As well, I'm confused about why the following has no effect
on the background (from a fresh start):
Only after I've run xyplot once, I can repeat
and the background will change.

thanks,
-Michael
#
On Fri, 6 Dec 2002, Michael Friendly wrote:

            
Both.  Try
trellis.par.set("fontsize", list(default=12))

but it is a bug in the grid package.
You need to open the device whose background you are trying to change:

trellis.device()
That should be detected (no trellis device open) and give an error or open
a device.
#
On Friday 06 December 2002 10:37 am, Michael Friendly wrote:
I get a much longer list.
You are doing this wrong. ?trellis.par.set gives an example of usage:


     `trellis.par.get' is usually used inside trellis functions to get
     graphical parameters before plotting. Modifications by users via
     `trellis.par.set' is typically done as follows:


     `add.line <- trellis.par.get("add.line")'

     `add.line$col <- "red"'

     `add.line <- trellis.par.set("add.line", add.line)'

(the assignment in the last line is redundant, sorry about that)

Your example, adapted to look like this, would have been:


fsize <- trellis.par.get("fontsize")
fsize$default <- 12
trellis.par.set("fontsize", fsize)

The point you are missing is the value argument to trellis.par.set should be a 
list, even when it has only one component. (I will change trellis.par.set to 
complain when value is not a list.)

A slightly easier way to do this is use

lset(list(fontsize = list(default = 12)))

(This becomes useful when the parameter you are changing has many components,  
but you are changing only one or two.)
That goes into xlab / ylab.
Same reason. Should be 

trellis.par.set("background", list(col = "white"))

or

lset(list(background = list(col = "white"))
Probably has to do with the fact that 

trellis.par.get("background")$col is now NULL.

Deepayan