[R] Lattice: finding out xlim within panel function
Paul Murrell
p.murrell at auckland.ac.nz
Tue May 4 02:52:40 CEST 2004
Hi
Deepayan Sarkar wrote:
> 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)
> }
Yep, the API for interrogating grid objects needs more work. On the
other hand, it's possible that you don't need to know the x- and
y-scales. You may be able to do what you want with the unit() function
and unit conversion functions (which are documented). Can you tell me
more about what you are trying to do?
Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list