[R] Centring ticks on hists

Marc Schwartz MSchwartz at medanalytics.com
Sun Sep 7 15:57:13 CEST 2003


On Sun, 2003-09-07 at 05:23, Philip Rhoades wrote:
> Hi people,
> 
> With:
> 
> 	hist(rnorm(200, 10, 3), breaks=20)
> 
> - how do I centre the ticks below each hist rectangle?
> 
> Thanks,
> 
> Phil.
> --
> Philip Rhoades


hist() returns a list of elements, one of which is 'mids', which are the
cell centers. Thus, use something like:

hist.data <- hist(rnorm(200, 10, 3), breaks=20, axes = FALSE)
axis(1, at = hist.data$mids)
axis(2)

See ?hist for more information.

HTH,

Marc Schwartz




More information about the R-help mailing list