Stacking multiple plots, vertically with the same x axis but different Y axes in R

前端 未结 4 581
既然无缘
既然无缘 2020-12-24 14:39

I have a data.frame with multiple time series vectors against a date:time vector. I would like to plot all of the relevant vectors, vertically stacked on separate graphs wit

4条回答
  •  遥遥无期
    2020-12-24 15:34

    I've actually figured out another interesting way of doing this with the zoo library:

    library(zoo)
    z <- with(dt, zoo(cbind(DEPTH, X, 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, ylim=list((rev(range(dt$DEPTH))), c(-90,90), c(-10,10), c(-10,10)))
    

    So within a zoo plot you can create new axis labels as a list form and all plots can have different colours.

提交回复
热议问题