From wolfram at fischer-zim.ch  Wed Mar  3 11:08:45 2004
From: wolfram at fischer-zim.ch (Wolfram Fischer)
Date: Thu Mar  4 11:23:27 2004
Subject: [Rd] lattice/grid: problem with viewports for strips with zero height
Message-ID: <20040303100845.GA2941@s1x.local>

PROBLEM
        # Allocating strip labels by the function strip.fun():

    strip.test()
        # Result: No strips: ok. No strings: NOT OK.
        # The distance ``y.text=unit(6,"points")'' is ignored;
        # the strings are not seen on the output.


TRIALS FOR WORKAROUNDS

    strip.test( strip.lines=1 )
        # Result: 2 strips: ok, but not whished. 2 strings: ok.

    strip.test( y.text=0 )
        # Result: No strips: ok. 2 strings: ok, but not pretty.

    strip.test( strip.lines=0.01 )
        # Result: 2 very narrow strips: ok, but not whished. 2 strings: ok.


CODE
    library( lattice )
    library( grid )
    data( barley )

strip.test <- function( strip.lines=0, y.text=unit( 6, "points" ), ... ){
    lset( list( clip = list( strip=F ) ) )
    strip.fun <- function( which.given, which.panel, factor.levels, ... ){
        grid.text( label=factor.levels[which.panel[which.given]] 
            , x= 0.5 - ( which.given - 1.5 ) * 0.7
            , y=y.text
            , just=c( c("right","left")[which.given], "bottom" )
            )
    }
    print( dotplot( variety ~ yield | year * site, data=barley
        , par.strip.text=list( lines=strip.lines )
        , strip=strip.fun
        , between=list( y=1.5 )
        , ...
        ))
}


Wolfram


[Rd] lattice/grid: problem with viewports for strips with zero height
Wolfram Fischer