[R] lattice/ylim: how to fix ylim[1], but have ylim[2] dynamically calculated?

David Winsemius dwinsemius at comcast.net
Sun Feb 14 18:54:29 CET 2010


On Feb 14, 2010, at 10:33 AM, Johannes Graumann wrote:

> Hello,
>
> When drawing "barcharts", I find it not helpful if ylim[1] != 0 -  
> bars for a
> quantity of 0, that do not show a length of 0 are quite non-intuitive.
>
> I have tried to study
> 	> library(lattice)
> 	> panel.barchart
> but am unable to figure out where ylim is taken care of and how one  
> might
> fix ylim[1] to 0 for barcharts ...
>
> Can anyone point out how to tackle this?

Looking at Sarkar's "Lattice" text in chapter 8 section 3 "Limits and  
Aspect Ratio", it appears from subsection 1 that the prepanel function  
can used to supply values of xlim and ylim values. From subsection 2  
he clarifies that xlim and ylim can also be specified on a per panel  
basis (and here I am guessing that this would be within a scales  
argument) when relation="free". At the end of that section he offers  
two examples using ylim: the first is not plotted but the second uses  
the prepanel mechanism for Fig 8.1 and that is probably available on  
the Lattice website.

In the same subsection is offered an alternative to specifying an  
explicit scales$y$limits to be interpreted as ylim values.

My hope it that these ideas and references will be of some use in  
identifying productive places to look for further documentation.

-- 
David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list