[R] y axis on hist

Jari Oksanen jarioksa at sun3.oulu.fi
Thu Dec 12 14:58:03 CET 2002


fpgibson at umich.edu said:
> 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)) 

If you use instead:

hist(rnorm(100000)); box()

You won't notice anything strange, and you may be satisfied with the result.

The `problem', if there is a problem, is pretty deep in the command axis() used 
by histogram plotting function plot.histogram(), and the behaviour is just same 
as in other R graphs which do not necessarily have tic marks at the axis 
extremes. You can see if you execute sequentially:

plot(rnorm(100), rnorm(100), axes=FALSE)
axis(1); axis(2)
box()

So it's a property, and using box() is the easiest way to hide this property, 
if you don't like it.

cheers, jari oksanen
-- 
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
Ph. +358 8 5531526, cell +358 40 5136529, fax +358 8 5531061
email jari.oksanen at oulu.fi, homepage http://cc.oulu.fi/~jarioksa/




More information about the R-help mailing list