Skip to content

bwplot(): Can Panel Heading Span Two Lines?

6 messages · David Winsemius, Rich Shepard, Bert Gunter

#
A conditioning factor for bwplot() is the stream name. There are 17
streams so each panel is comparatively small and the names in the panel
header are truncated at both ends. I would like to wrap the names on two
lines for each panel but do not see if this can be done when I look at the
online docs (?bwplot) or the Lattice book. Is there a way to fit long
strings as headers with multiple panels on a page?

Rich
#
On Sep 10, 2012, at 11:35 AM, Rich Shepard wrote:

            
The text that appears in the "panel header" is called the "strip". I didn't see it in the help page for bwplot. You need to look at:

 ?strip.custom.

And since you have the Lattice book look at section 10.7 'Controlling the appearance of strips"
#
On Mon, 10 Sep 2012, David Winsemius wrote:

            
David,

   That explains why I did not find it in the book's index.
Thanks very much!

Rich
#
In addition, try this:

x <- rep(1:10,2); y <- runif(20);f<-factor(rep(paste("This
is\nLevel",1:2),e=10))
xyplot(y~x|f,
  par.strip.text=list(lineheight=.8,lines=3))

I find the documentation here confusing and incomplete:
"par.strip.text" is listed as a parameter both in ?xyplot and
?strip.custom. The arguments are apparently different in the two
cases, although they are not clearly spelled out in either, although I
would guess that the default setting in ?strip.default, "add.text,"
may explain strip.default's. Note that the "lines" component is
missing, for strip.custom() but apparently works in xtplot().

Cheers,
Bert
On Mon, Sep 10, 2012 at 1:33 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:

  
    
#
On Sep 10, 2012, at 1:48 PM, Bert Gunter wrote:

            
Bert;

  I had imagined that the factor level character strings could be automagically separated by substituting '\n' at each space or dash or wahtever:

strip.new <- function( which.given, which.panel, factor.levels, ...){ 
                 panel.text( x=0.5,y=1.5, lab=gsub("\\ ", "\n", factor.levels) )}

# Need to tweak the line height

xyplot(y~x|f, strip=strip.new)

Your approach of changing the levels to be pre-split with '\n's may be more straightforward.
#
On Mon, 10 Sep 2012, Bert Gunter wrote:

            
Bert,

   Thanks very much. If the docs are less than clear to you, they will
certainly be rather opaque to me.

Rich