Didzis Elferts 的答案是一个很好的答案。我只是要注意,当您处理时间序列时,您可以使用xts
package.json 。特别是该情节是在基本图形中完成的。这里有一个例子:
- 我
monthly.apply
用来分割我的对象。
- 我使用 plot.xts 来绘制我的时间序列。
首先,我生成一些随机数据
library(xts)
days <- seq.Date( as.Date("2011-01-01"), as.Date("2011-12-31") ,1)
dat <- xts(rnorm(365),days)
## I use monthly apply to compute months widths.
## no need to give them by hand.
widths <- coredata(apply.monthly(dat,length))
par(bg="lightyellow", mar=c(2,2,2,0))
layout(matrix(c(rep(1,12),2:13),nrow=2,byrow=T),widths=widths*2)
mon <- months(days,abbreviate=T)
plot(dat,main = 'my year time series')
apply.monthly(dat,function(x) {
if(unique(format((index(x)),'%m')) =='01') {#JAN
par(mar=c(2,2,2,0)) ## special case of JAN because it contians y axis
plot(x,main='')
}
else{
par( mar=c(2,0,2,0))
plot(x,main='',ylab='')
}
})

请注意:JAN 面板不小于 2 月 1 日。它包含 y 轴。