[R] adding infrequent date labels to x-axis

emorway emorway at engr.colostate.edu
Mon Feb 22 18:21:39 CET 2010


I'm sure there is a clever way to do the following, but I've been unable to
find it on this forum or by writing my own functions.  I have 8 years worth
of weekly data but would like to restrict the labels on the x-axis to months
only.  I've included the first year's worth of data below. 

My line of thought has been along these lines

x<-seq(as.Date("1999-04-01"),as.Date("2007-10-25"),by="1 month")
y<-as.POSIXlt(x)$mon+1
months<-month.name
month.names<-months[as.numeric(y)]
month.names<-substr(month.names,1,3)

plot(cropped.cast1$date,cropped.cast1$Frac_ET_Satsfd_mean,xaxt='n')
mtext(text=month.names,side=1,at=???

I'm not sure how to tie "month.names" back to their true location on the
x-axis?

I appreciate any insights, Eric
Also,

>class(cropped.cast1$date)
[1] "POSIXt"  "POSIXct"

>cropped.cast1
      date Frac_ET_Satsfd_mean Frac_ET_Satsfd_sd
1999-04-08           0.8344885        0.13545515
1999-04-15           0.8355466        0.12810387
1999-04-22           0.8595579        0.11259251
1999-04-29           0.8997225        0.09611060
1999-05-06           0.8714364        0.09527164
1999-05-13           0.8530203        0.11088544
1999-05-20           0.8437866        0.12689882
1999-05-27           0.8310003        0.13985307
1999-06-03           0.8031203        0.15851422
1999-06-10           0.8288505        0.12827027
1999-06-17           0.8251130        0.13051783
1999-06-24           0.8227639        0.14227501
1999-07-01           0.7914689        0.15892716
1999-07-08           0.8050929        0.14465413
1999-07-15           0.8370141        0.11843615
1999-07-22           0.8448697        0.10823010
1999-07-29           0.8561925        0.10694348
1999-08-05           0.8520790        0.09953065
1999-08-12           0.8429925        0.10545427
1999-08-19           0.8397966        0.11629002
1999-08-26           0.8367953        0.12363411
1999-09-02           0.8219479        0.13870596
1999-09-09           0.8218193        0.13617427
1999-09-16           0.8217584        0.13346997
1999-09-23           0.8216834        0.13304117
1999-09-30           0.8111005        0.14367143
1999-10-07           0.8090813        0.14967750
1999-10-14           0.8265188        0.13484263
1999-10-21           0.8391333        0.11873929
1999-10-28           0.8426102        0.11215439
1999-11-04           0.8431813        0.11007485
1999-11-11           0.8394140        0.11206864
1999-11-18           0.8350650        0.11042384
1999-11-25           0.8360082        0.11011926
1999-12-02           0.8362129        0.10834491
1999-12-09           0.8377512        0.10519698
1999-12-16           0.8367339        0.10176535
1999-12-23           0.8338621        0.10273662
1999-12-30           0.8317094        0.10470654
-- 
View this message in context: http://n4.nabble.com/adding-infrequent-date-labels-to-x-axis-tp1564804p1564804.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list