Dear R People: I have the following montly time series>ya.tsJan 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>plot(ya.ts)When the plot is constructed, the ticks on the horizontal (time) axis are 2001.0, 2001.5, and so on. Is there a way to set up ticks such as J,F,M,A,M......by months, please? Thank you! Sincerely, Laura Holt mailto: lauraholt_983 at hotmail.com
? par ? axis basically you turn off the default labels and give your vector of character labels ----- Original Message ----- From: "Laura Holt" <lauraholt_983 at hotmail.com> To: <r-help at stat.math.ethz.ch> Sent: Monday, August 16, 2004 10:59 PM Subject: [R] ticks on the Time Axis> Dear R People: > > I have the following montly time series > >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 > >plot(ya.ts) > > When the plot is constructed, the ticks on the horizontal (time) axis are > 2001.0, 2001.5, and so on. > > Is there a way to set up ticks such as J,F,M,A,M......by months, please? > > Thank you! > Sincerely, > Laura Holt > mailto: lauraholt_983 at hotmail.com > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html
Laura Holt <lauraholt_983 <at> hotmail.com> writes: : : Dear R People: : : I have the following montly time series : >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 : >plot(ya.ts) : : When the plot is constructed, the ticks on the horizontal (time) axis are : 2001.0, 2001.5, and so on. : : Is there a way to set up ticks such as J,F,M,A,M......by months, please? This is not quite what you are asking for since the months are in numbers (Jan = 01) and it may print only every third month if its too cramped but its easy (no messing with axes) and it may be good enough. It uses the fact that the chron package will plot numeric months and years. require(chron) ya.start.date <- chron("1/1/1") ya.dates <- seq(ya.start.date, length = length(ya.ts), by = "month") plot(ya.dates, ya.ts) If you want to automatically construct ya.start.date above from ya.ts, use the fact that year-month-day character format is accepted by Date to get the start date as a Date, convert that to chron and then use that in place of the ya.start.date <- line above: ya.start.date <- chron(as.Date(paste(c(start(ya.ts),1), collapse="-")))