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

Wolfram Fischer wolfram at fischer-zim.ch
Wed Mar 3 11:08:45 MET 2004


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



More information about the R-devel mailing list