Skip to content

location of key in panels of trellis plot

2 messages · Steven Lacey, Paul Murrell

#
Hi

Here's a modification of your panel function that I think does what you 
want (comments embedded):

tmp.xyplot <- function(x,y,subscripts=subscripts,cdata=cdata){
     # plot data points
     panel.xyplot(x,y)
     # extract parameter values
     right <- as.character(cdata[subscripts,][1,c(4,5,6)])
     #### Create the key for the panel
     key <- draw.key(list(text=list(expression(t[1],t[infinity],"p")),
                          text=list(c("=","=","=")),
                          text=list(right),
                          between=c(0.4),
                          rep=FALSE,
                          columns=1,
                          column.between=0),
                     draw=FALSE)
     #### Push a viewport in the top-right corner which is
     #### big enough to fit the key
     #### Uses grobWidth() and grobHeight() to get the size of the key
     #### (You'll need a library(grid) somewhere to direct access
     ####  to these grid functions)
     pushViewport(viewport(x=1, y=1,
                           width=grobWidth(key),
                           height=grobHeight(key),
                           just=c("right", "top")))
     #### Draw the key
     grid.draw(key)
     #### Pop the key viewport
     popViewport()
}

Hope that helps

Paul
Steven Lacey wrote: