[R] how to specify the location of tick mark on x axies

Duncan Murdoch murdoch at stats.uwo.ca
Sat Feb 16 13:46:47 CET 2008


Xin wrote:
> Dear:
>
>     I want to plot barplot and let bar be in the middle of each x axis category.
>  
>    Do you have this experience?
>  
>    Many Thanks!
>
>    Xin
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>   
 > x <- rnorm(100)
 > h <- hist(x, axes=F)
 > str(h)
List of 7
 $ breaks     : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
 $ counts     : int [1:9] 2 7 23 17 28 9 10 2 2
 $ intensities: num [1:9] 0.04 0.14 0.46 0.34 0.56 ...
 $ density    : num [1:9] 0.04 0.14 0.46 0.34 0.56 ...
 $ mids       : num [1:9] -1.75 -1.25 -0.75 -0.25 0.25 0.75 1.25 1.75 2.25
 $ xname      : chr "x"
 $ equidist   : logi TRUE
 - attr(*, "class")= chr "histogram"
 > axis(1, at=h$mids)

I'd say that graphically it's not the best idea, but it's not hard to 
do.  If you want variations, see the manual pages ?hist, ?axis, etc.

Duncan Murdoch



More information about the R-help mailing list