[R] two labels on x-axis (year and month)

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Aug 23 10:25:42 CEST 2007



mgilgen at swissonline.ch wrote:
> hej
> 
> i'm plotting time-series and label the x-axis as follows:
> 
> r <- as.POSIXct(round(range(p1$time), "month"))
> 
> to define the time range for labeling the xaxis
> 
> plot(p1$time,p1$ p1, type="l", xaxt="n")
> 
> plots p1 against time
> 
> axis.POSIXct(1, at=seq(r[1], r[2], by="month"), format="%m")
> 
> labels the axis in mothly steps.
> 
> what I want do do now, is a second label for the x-axis, that stands lower and indicates the years.
> 
> like 05 06 07 08 09 10 11 12 01 02 03 04 05 etc...
>              2004                                  2005
> I don't know how to proceed with all the possibilities in axis, par and plot

You can add the year numbers manually with mtext() (for plotting text 
into the margins).

Uwe Ligges




> thanks for your help
> 
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list