Re: [S] x axis limits on barchart

Jan Schelling (schelling@ivuk.mavt.ethz.ch)
Tue, 26 May 1998 16:24:16 +0200


Douglas,

not an elegant solution, but maybe a useful approach is to force the left
limit of the x-axis of a barchart to zero by reversing the default
behaviour of S:

your example:

tiger <- data.frame( proportion = c(9.5, 8.8, 3.1, 1.7, 1.2, 0.1),activity
= c("Sleeping", "Pacing", "Feeding", "Grooming", "Vocalizing", "Hunting"))
barchart( activity ~ proportion, data = tiger,
xlim=max(tiger$proportion)*c(.04/(1+.04), 1))

-----------------------------------------------------------------
Jan Schelling
Institute of Process Engineering
ETH Zurich, 8092 Switzerland
phone: ++41-1-633 62 63
fax: ++41-1-633 11 19
email: schelling@ivuk.mavt.ethz.ch
internet: http://www.ivuk.ethz.ch/staff/schelling/
-----------------------------------------------------------------

At 22:00 25.05.98 -0500, Douglas Bates wrote:
>I was using barchart today to prepare some graphs for a paper when I
>noticed that the size of the bars was misleading because the bars did
>not start at zero. The data I was plotting looked like
>
> tiger <- data.frame( proportion = c(9.5, 8.8, 3.1, 1.7, 1.2, 0.1),
> activity = c("Sleeping", "Pacing", "Feeding", "Grooming",
> "Vocalizing", "Hunting"))
> barchart( activity ~ proportion, data = tiger )
>
>On this barchart the extent of the x axis is based on the range of the
>data extended about 3%-4% at both ends according to the default rules
>for axes in S. In this case the x axis extends on the left to about
>-0.1 or -0.2. Since the bars are drawn from the left end of the axis,
>not from the zero position, they give the visual impression that the
>proportion for hunting is much larger than it actually is.
>
>I understand the rationale for the default scaling of axes in S but I
>think that a barchart is probably a case where you want to be able to
>specify the left boundary of the axis to be zero so the size of the
>bars corresponds to the relative size of the data values. I tried
>playing with various arguments in scale and xaxt, etc. but was unable
>to achieve this. I would welcome suggestions of how to enforce the
>left limit of the x axis being zero.
>--
>Douglas Bates bates@stat.wisc.edu
>Statistics Department 608/262-2598
>University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/
>-----------------------------------------------------------------------
>This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
>send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
>message: unsubscribe s-news
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news