[R] A question on histogram (hist): coordinates on x-axis are too sparse

Duncan Murdoch murdoch at stats.uwo.ca
Wed Jan 21 13:26:45 CET 2009


Li, Hua wrote:
> Dear R helpers:
>      Let's say I have some data  X,   
>      X <- runif(1000, 1, 10000000000)
>      pdf('X.pdf', width=100,height=5)
>      hist(X, breaks=1000)
>      dev.off()
>      I find that, on x-axis the coordinates are  0e+00,  2e+09, 4e+09, 6e+09, 8e+09, 1e+10.  Only five numbers, which is too sparse in a 100x5 pdf file.  I want the x-axis coordinates to become more dense,  e.g.  0e+00,  1e+09, 2e+09, 3e+09,..... 8e+09, 9e+09,  1e+10.  What argument (or function) should I revise to let this happen??
>      Thanks a lot!!
> Best, Hua
You can draw the axes yourself:

hist(X, axes=F)
axis(1, at=pretty(X, n=100))
axis(2)
box()

Duncan Murdoch




More information about the R-help mailing list