user1094628
user1094628

Reputation: 239

R - Customizing X Axis Values in Histogram

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.

Upvotes: 21

Views: 126558

Answers (1)

Josh O'Brien
Josh O'Brien

Reputation: 162311

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))

Upvotes: 32

Related Questions