[R] Lattice: finding out xlim within panel function

Paul Murrell p.murrell at auckland.ac.nz
Tue May 4 22:58:19 CEST 2004


Hi


Lutz Prechelt wrote:
>>>>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?
>>>
> ...
> 
>>>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:
>>>
>>>    cvp = grid::current.viewport() 
>>>    print(cvp$xscale)
>>
> ...
> 
>>Can you tell me 
>>more about what you are trying to do?
> 
> 
> I am writing a panel function that will (among other
> things) plot a regression line for a scatter plot
> and add curves for confidence or prediction intervals.
> I want the intervals to cover not only the
> x-range of the data, but the whole length of the
> axis.
> 
> And while for drawing the line I need not know
> the size of the scale (by using abline),
> there is nobody taking it off me to decide where
> to start and stop drawing the curves for the
> intervals.


Yep, sounds like you need the x-scale alright :)
If you want something that is documented (and therefore much less likely 
to change in future grid versions), the following call will also give 
you the x-axis range:

convertX(unit(0:1, "npc"), "native", valueOnly=TRUE)

Thanks for the extra info.

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