[R] change y axis "distance"

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Sep 21 13:29:09 CEST 2010


On Tue, 2010-09-21 at 03:55 -0700, Joel wrote:
> Hi
> 
> I got a barplot that has values between 0-150 and the y-axis shows the steps
> 0 50 100 and 150 but I would like to change it to 0 10 20 30... ...130 140
> 150
> 
> Dont really know the word in english so sry about it beeing abit confusing
> :)
> 
> Thx for your help 
> Joel

If you want to draw the ticks at specific locations rather than the ones
R chooses for you, turn off the axes in your plot call and then cook
your own axis using the axis() function.

Here's an example using dummy data:

set.seed(123)
mdat <- rpois(10, 10)
names(mdat) <- LETTERS[1:10]
barplot(mdat, axes = FALSE)
## label at 1, 2, 3 etc not 2, 4, 6, etc
axis(side = 2, at = seq(1, max(mdat), by  = 2))

For you specific axis call, try:

axis(side = 2, at = seq(0, 150, by = 10))

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list