[R] Lattice: finding out xlim within panel function

Deepayan Sarkar deepayan at stat.wisc.edu
Mon May 3 17:44:20 CEST 2004


On Monday 03 May 2004 09:36, Lutz Prechelt wrote:
> Dear Lattice bit-meddlers,
>
> while within a panel function for xyplot, how can I
> find out the values of (effectively) xlim and
> ylim -- no matter whether they have been set
> explicitly or chosen by Lattice itself?
>
> I have just tried for an hour to find out,
> with no success whatsoever.
> I looked in Grid for something that would
> return such data, but got lost.
> I looked at tracebacks of panel calls, but
> couldn't see the forest for the trees.

Not surprising, since there's no documented way to do this. You could 
try something along these lines, but this exact construct is not 
guaranteed to work in future versions of grid:

panel = function(...) {
    cvp = grid::current.viewport() 
    print(cvp$xscale)
    print(cvp$yscale)
}

Deepayan




More information about the R-help mailing list