Re: [R] How to set the parameters in Trellis Graphics (by Lattice package)

From: Felix Andrews <>
Date: Tue, 29 Jul 2008 23:00:49 +1000

On Tue, Jul 29, 2008 at 5:37 PM, G.H. Zuo <> wrote:
> Dear R users
> I plot the trellis graphics by using the lattice package. Everything is
> OK. Now, I want set
> some parameters of the trellis graphics.
> 1. The tick label site. By default, only two tick labels had been output in
> x-axis of my plot.
> I want output four or five tick labels. In the traditional graphics system,
> it will be very easy.
> Just not output the axis in plot by use the parameter xaxt="n", and then
> used axis to add
> the axis. But it seem useless in the grid graphics system. Then how can I
> do it?

You would generally use scales=list(ticks=5) or scales=list(x=list(ticks=5)). See the entry for "scales" in ?xyplot
However, the default (suggested) number of ticks is 4 or 5, so there may be something odd about your case. How about a reproducible example?

> 2. How to change the margin of the figure?

Why do you want to do that? Grid graphics automatically allocates enough space for the objects to be displayed. If you really want to, there are ways to do it, but I suggest you do not. You are more likely looking for the "aspect" argument.

> 3. Can I change the style of the figure like par in traditional system. For
> example, I want
> change all the fontface into bold. Now, I must change the fontface for
> every item by using
> command trellis.par.set() like this:
> trellis.par.set(list(par.xlab.text = gpar(font = 2),
> par.ylab.text = gpar(font = 2),
> axis.text = gpar(font = 2),
> add.text = gpar(font=2)
> ))
> is there a method to change this parameter in one time, like par(font=2)

You can try trellis.par.set(fontsize=list(text=14)) which is similar. Otherwise you could write a function to set the font parameters; this could be modified from latticeExtra::custom.theme

> thanks
> G.H.Zuo
> [[alternative HTML version deleted]]
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.

Felix Andrews / 安福立
PhD candidate
Integrated Catchment Assessment and Management Centre
The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 29 Jul 2008 - 13:02:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Jul 2008 - 13:32:46 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive