[R] Changing strip widths in lattice plots

Deepayan Sarkar deepayan at stat.wisc.edu
Fri Nov 23 03:40:12 CET 2001


--- "Andrew C. Ward" <s195404 at student.uq.edu.au> wrote:
> Hello R users,
> 
> I'm using xyplot (lattice) to plot some data.
> Unfortunately, the text that goes 
> into each strip is often too big to fit. For
> instance, one of the factors may 
> be labelled "Satisfaction with waiting time" which
> is too wide to fit. If I use 
> split.string() to wrap it onto two lines it is then
> too high to fit in the 
> strip. I'd prefer to apply split.string on the fly
> than manually shorten each 
> offending label.
> 
> I thought I could try
>    1. making the strip wider (in the y direction) or
>    2. removing it altogether and adding the strip
> text with ltext()
> 
> strip.default seemed a good place to look. I
> commented out any rect() 
> statements, but the strips were still drawn. Could
> someone please tell me where 
> to look for adjusting the strip width (or removing
> it entirely).


The strip can be removed by calling xyplot with strip=F. To increase its
height (to double the current height, say),  you would have to change the
print.trellis function. In "print.trellis.R" in the package source, change 

for(crr in 1:number.of.cond)
   heights.x[number.of.cond + 4 + (1:rows.per.page - 1)*(number.of.cond+3) -crr] <-
       if (is.logical(x$strip)) 0  # which means strip = F, strips not to be drawn
       else x$par.strip.text$cex

(lines 865-868) to

for(crr in 1:number.of.cond)
   heights.x[number.of.cond + 4 + (1:rows.per.page - 1)*(number.of.cond+3) -crr] <-
       if (is.logical(x$strip)) 0  # which means strip = F, strips not to be drawn
       else 2 * x$par.strip.text$cex


Hope that gives what you want.

- Deepayan

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list