[R] plot custom x axis ticks values

Jim Lemon jim at bitwrit.com.au
Fri Feb 15 04:13:57 CET 2013


On 02/14/2013 09:41 PM, e-letter wrote:
> Readers,
>
> For this data set:
>
> testvalues<-c(10,20,30,40)
>
> How to amend the plot instruction:
>
> plot(testvalues,ann=FALSE,type='l',yaxt='n',xaxt='n')
>
> so that x axis ticks labels can be added to existing graph with
> arbitrary value such as 0,100,200,300)?
>
Hi r2151,
If you want the labels to fit on the axis you will have to include this 
information in the call to "plot":

plot(testvalues,ann=FALSE,type='l',yaxt='n',xaxt='n',ylim=c(0,300))
axis(2,at=c(0,100,200,300))

As you may be adding more values after the first set, the same goes for 
the X axis if there are different numbers of Y values.

Jim



More information about the R-help mailing list