[R] histogram plot spacing problem

Rui Barradas ruipbarradas at sapo.pt
Wed Sep 19 22:02:12 CEST 2012


Hello,

Try the following.


x <- rnorm(100)
hist(x, xaxt = "n")
axis(1, at = pretty(x), pos = 0)

Hope this helps,

Rui Barradas
Em 19-09-2012 18:51, firespot escreveu:
> Hi,
>
> So I plot a histogram using the built-in hist function:
>
> hist(rnorm(100), ...).
>
> Now the y-axis starts at its lower end at 0 (very sensible, of course) 
> and that's where the baseline for the rectangles of the histogram is 
> drawn, but the x-axis itself is offset a bit to the lower. I.e. there 
> is some space between x-axis and null-point of y-axis / histogram 
> lower end.
> What do I need to do to get rid of that space, so that x- and y-axis 
> will intersect at y=0 ? Ideally the solution should be device- and 
> screen-size independent.
>
> thanks!
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list