[R] Months on the horizontal axis

Laura Holt lauraholt_983 at hotmail.com
Tue Aug 17 06:47:46 CEST 2004


Dear R People:

Just in case anyone is interested, here is a particular solution to the 
months on the horizontal axis question:

>mon1
[1] "J" "F" "M" "A" "M" "J" "J" "A" "S" "O" "N" "D"
>mon2 <- rep(mon1,2)
>mon2
[1] "J" "F" "M" "A" "M" "J" "J" "A" "S" "O" "N" "D" "J" "F" "M" "A" "M" "J" 
"J"
[20] "A" "S" "O" "N" "D"
>ya.ts
      Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
2001  3.7 -0.8  0.3 -1.5 -0.2 -0.4  2.5 -1.0 -1.2 -1.2  0.4 -0.5
2002  0.5  0.0 -0.8 -1.0  0.6  0.8 -0.5 -2.4  1.3  1.4 -0.1  0.5
>mon1
[1] "J" "F" "M" "A" "M" "J" "J" "A" "S" "O" "N" "D"
>mon2 <- rep(mon1,2)
>mon2
[1] "J" "F" "M" "A" "M" "J" "J" "A" "S" "O" "N" "D" "J" "F" "M" "A" "M" "J" 
"J"
[20] "A" "S" "O" "N" "D"
>#I looked at the original plot
>plot(ya.ts)
>#Now I start cleaning things up
>plot(ya.ts,axes=F,ylab=" ",xlab="2001 - 2002",ylim=c(-3,4))
md1 <- ((0:23)/12)+2001
>md1
[1] 2001.000 2001.083 2001.167 2001.250 2001.333 2001.417 2001.500 2001.583
[9] 2001.667 2001.750 2001.833 2001.917 2002.000 2002.083 2002.167 2002.250
[17] 2002.333 2002.417 2002.500 2002.583 2002.667 2002.750 2002.833 2002.917
>axis(1,at=md1,labels=mon2,pos=-3)
>axis(2,pos=2001)
>title("Months on the Horizontal Axis")
>

Thanks for listening and thanks for the many kind responses.

Sincerely,
Laura
mailto: lauraholt_983 at hotmail.com




More information about the R-help mailing list