使用R中的zoo.plot替换y轴

时间:2012-08-03 16:56:21

标签: r data-visualization zoo

我正在使用zoo.plot绘制一个多重的叠加图,在1 x轴上有4个y轴。有没有办法在y轴标记和刻度标记的一侧交替,以便它们不在同一侧重叠。即顶部图,y轴在左边,下一个图在右边,依此类推?

我的情节代码如下:

library(zoo)
z <- with(df, zoo(cbind(depth, angle, Y, Z),as.POSIXct(time))) 
plot.zoo(z,  ylab=c("Depth (m)", "Pitch Angle (degrees)", "Swaying Acceleration (m/s^2)", "Heaving Acceleration (m/s^2)"), col=c("black", "blue", "darkred", "darkgreen"), 
     xlab = c("Time"), lwd=2, plot.type="multiple", ylim=list((rev(range(dive195.11drift$DEPTH))), c(-90,90), c(-10,10), c(-10,10)))

1 个答案:

答案 0 :(得分:1)

我认为你必须自己做:

z <- zoo(cbind(a = 1:10, b = 10:1, c = rep(1:5, each = 2))) # test data

nc <- ncol(z)
opar <- par(mfrow = c(nc, 1), mar = c(2, 2, 1.5, 2))
for(i in 1:nc) { plot(z[, i], yaxt="n", main=colnames(z)[i]); axis(2+2*i%%2) }