Skip to content
Prev 69997 / 398506 Next

Lattice: how to get default ylim?

Hi,

Within your panel function you can use current.viewport() to recover
the active grid viewport and get xlim/ylim (in addition to other very
useful information).  Then you can use grid.text (plus any other
grid.* function), e.g.,

  require(grid)     

  my.panel <- 
  function(...)
  {
     panel.xyplot(...)
  
     ## add "Hello World on the top-left of each panel
  
     v <- current.viewport()        ## requires R 2.1.0 (I believe)
     xlim <- v$xscale
     ylim <- v$yscale
     grid.text(x = xlim[1], y = ylim[2], default.units="native",
        label = "Hello World", just= c("left", "top"))
  }

Hope this helps.

--
David
Wladimir Eremeev wrote: