[R] lattice: labelling shingles

Deepayan Sarkar deepayansarkar at yahoo.com
Fri May 10 14:48:20 CEST 2002


There isn't an 'easy' way, as far as I can see. You can always write your own
strip function (the arguments it takes is documented in ?strip.default). The
part for shingles in strip.default is short and should be easily modifiable. It
should be something along the lines of :

strip.new <-
    function(which.given,
             which.panel,
             var.name,
             factor.levels,
             shingle.intervals,
             strip.names = c(FALSE, TRUE),
             style = 1,
             bg = trellis.par.get("strip.background")$col[which.given],
             fg = trellis.par.get("strip.shingle")$col[which.given],
             par.strip.text = trellis.par.get("add.text"))
{
    name <- var.name[which.given]
    level <- which.panel[which.given]
    strip.names <- rep(strip.names, length = 2)
    
    if (is.null(factor.levels)) { # means this is a  shingle, as opposed to a  
     
                                  ## factor
        if (is.null(shingle.intervals)) 
           stop("both factor.levels and shingle.intervals cannot be NULL")

        strip.names <- strip.names[2]
        grid.rect(gp = gpar(fill=bg))
        t <- range(shingle.intervals)
        r <- (range(shingle.intervals[level,])-t[1])/diff(t)
        grid.rect(x = unit(r%*%c(.5,.5),"npc"), width = unit(diff(r),"npc"),
                  gp = gpar(col=fg, fill=fg))
        if (strip.names) grid.text(label = paste(shingle.intervals[level,1],
                                   shingle.intervals[level, 2], sep = ' , '),
                                   gp = gpar(col = par.strip.text$col,
                                   font = par.strip.text$font,
                                   fontsize = par.strip.text$cex *
                                   current.viewport()$gp$fontsize))
        
        grid.rect()
    }
    else strip.default(which.given,
                       which.panel,
                       var.name,
                       factor.levels = factor.levels,
                       shingle.intervals = shingle.intervals,
                       strip.names,
                       style,
                       bg,
                       fg,
                       par.strip.text)
}



--- "Martin Henry H. Stevens" <HStevens at muohio.edu> wrote:
> How do I control the text in strips? Specifically, I want to put in the 
> ranges generated in shingle(x) where x is continuous.
> Thanks,
> Hank
> 
> Martin Henry H. Stevens, Assistant Professor
> 338 Pearson Hall
> Botany Department
> Miami University
> Oxford, OH 45056
> 
> Office: (513) 529-4206
> Lab: (513) 529-4262
> FAX: (513) 529-4243
> http://www.muohio.edu/~botcwis/bot/henry.html
> 
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


__________________________________________________

Yahoo! Shopping - Mother's Day is May 12th!

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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