[R] Adjusting X-axis time scale
Jim Lemon
jim at bitwrit.com.au
Sun Apr 4 13:20:20 CEST 2010
On 04/04/2010 08:52 PM, zowiti at ncst.go.ke wrote:
> Dear all,
>
> I am plotting daily data from 1950 to 2000 and I wish to have the time in
> X-axis to indicate years and NOT days (i.e 1950 1951,......,2000 instead of
> 1,2, 3, ......).
> How do I set the x-axis to show years instead of days.
>
Hi Zablone,
At a guess, try this:
plot(...,xaxt="n")
axis(1,at=1:51,labels=1950:2000)
although unless you have a _very_ wide plot, only a few of the labels
will be shown, so you may want:
axis(1,at=seq(1,51,by=10),labels=seq(1950,2000,by=10))
or if you really want those 51 labels:
plot(...,xaxt="n",xlab="")
library(plotrix)
staxlab(1,at=1:51,labels=1950:2000,nlines=4)
Jim
More information about the R-help
mailing list