[R] y axis on hist
Paul Murrell
p.murrell at auckland.ac.nz
Thu Dec 12 22:49:02 CET 2002
Hi
Note also that box() can take a bty argument (see help(par)) so you
don't have to draw all four sides. For example ...
hist(rnorm(100000))
box(bty="l")
Paul
Peter Dalgaard BSA wrote:
>
> Bud Gibson <fpgibson at umich.edu> writes:
>
> > Hi:
> >
> > The y axis on the hist function seems to set its limits oddly.
> > sometimes, it covers the full range of the data and sometimes it stops
> > one major tick short. I have had this behavior with a variety of data
> > sets, and it can easily be reproduced by just running the following
> > several times:
> >
> > hist(rnorm(100000))
> >
> > I have tried explicitly setting ylim to the range of values produced
> > by rnorm (taking care to set some variable to rnorm(100000) and then
> > graphing that), and I still get the y axis plotting behvior I just
> > described.
>
> I don't think this is stranger than the axes on any other plots. It's
> just that the bounding box isn't printed on histograms. Try adding a
> box() and you'll see what the issue is. To ensure that the last axis
> label is "over the top", it is not enough to diddle the ylim to the
> range of barheights; you'll need to ensure that the ylim is also a
> pretty value, something like this:
>
> z <- rnorm(100000)
> h <- hist(z,plot=F)
> plot(h,ylim=range(pretty(range(0,h$counts))))
>
> --
> O__ ---- Peter Dalgaard Blegdamsvej 3
> c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
--
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
More information about the R-help
mailing list