tags:

views:

66

answers:

1

I have some 100k values. When I plot them as a line in R (using plot(type="l") the numbers next to the x-axis ticks are printed in scientific format (e.g. 0e+00,2e+04,...,1e+05). Instead, I would like them to be:

A) 0,20kb,...,100kb

B) the same but now the first coordinate should be 1 (i.e. starting to count from 1 instead of 0).

BTW R arrays use numbering that starts from 1 (in contrast to arrays in perl, java etc.) so I wonder why when plotting "they" decided starting from 0...

+1  A: 

A)

R> xpos <- seq(0, 1000, by=100)
R> plot(1:1000, rnorm(1000), type="l", xaxt="n")
R> axis(1, at=xpos, labels=sprintf("%.2fkb", xpos/1000))

B) same as above, adjust xpos

rcs
this is not correct. you just add "kb" next to the number, but leave the number unchanged (instead of dividing them by 1000)
David B
at least give the guy a vote for correct answer now
John