在 BlankUsername 的帮助下,我找到了以下zoo
时间序列解决方案。我以前不知道类似par(new=T)
或axis()
命令的东西:
# plot the usual data
plot(D)
# add half day to indicate that P is a sum of the whole day
index(P) <- index(P) + 0.5
# define an overlay plot without border
par(bty="n", new=T)
plot(P, type="h", ylim=rev(range(P)), # downward bars by BlankUsername
yaxt="n", xaxt="n", ann=F, # do not plot x and y axis
xlim=c(start(D),end(D)), # without xlim the two overlayed plots will not fit
lwd=10, col=rgb(0,0,0,0.1) ) # suggested cosmetics
# add right axis (4) to describe P
axis(4, pretty(range(P)), col.axis="grey", col="grey", las=1, cex.axis=0.7 )
# reset border and overlay
par(bty="o", new=F)