Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - Customizing X Axis Values in Histogram

Tags:

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.

like image 984
user1094628 Avatar asked Dec 12 '11 22:12

user1094628


1 Answers

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))
like image 74
Josh O'Brien Avatar answered Sep 30 '22 19:09

Josh O'Brien