[S] x axis limits on barchart

Douglas Bates (bates@stat.wisc.edu)
25 May 1998 22:00:45 -0500

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