21

I want to change the values on the x axis in my histogram in R.

The computer currently has it set as

0, 20, 40, 60, 80, 100.

I want the x axis to go by 10 as in:

0,10,20,30,40,50,60,70,80,90,100.

I know to get rid of the current axis I have to do this

(hist(x), .... xaxt = 'n')

and then

axis(side = 1) .....

But how do I get it to show the numbers that I need it to show?

Thanks.

agamesh
  • 559
  • 1
  • 10
  • 26
user1094628
  • 239
  • 2
  • 4
  • 5

1 Answers1

31

The answer is right there in ?axis...

dat <- sample(100, 1000, replace=TRUE)
hist(dat, xaxt='n')
axis(side=1, at=seq(0,100, 10), labels=seq(0,1000,100))
Josh O'Brien
  • 159,210
  • 26
  • 366
  • 455