Johannes Graumann
2010-Feb-14 15:33 UTC
[R] lattice/ylim: how to fix ylim[1], but have ylim[2] dynamically calculated?
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? Thanks, Joh
David Winsemius
2010-Feb-14 17:54 UTC
[R] lattice/ylim: how to fix ylim[1], but have ylim[2] dynamically calculated?
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
Deepayan Sarkar
2010-Feb-14 18:03 UTC
[R] lattice/ylim: how to fix ylim[1], but have ylim[2] dynamically calculated?
On Sun, Feb 14, 2010 at 7:33 AM, Johannes Graumann <johannes_graumann at web.de> 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?Are you sure you are not looking for 'origin=0' (described in ?panel.barchart)? -Deepayan