默认调用高级绘图函数的时候,会另外在绘制一副图,为了将两幅图绘制在同一张纸上,可以设置new = TRUE
代码示例:
plot(1:5, c(2,3,2,3,2), col = "red", type = "l", xlim = c(1,5), ylim = c(1,5), ylab = "", xlab = "") par(new = TRUE) plot(1:5, c(3,4,3,4,3), col = "blue", type = "l", xlim = c(1,5), ylim = c(1,5), ylab = "y", xlab = "x")
效果图如下:
需要注意的是,前后两幅图数据的区间可能不一致,需要对x轴和y轴进行调整,使两幅图叠加的效果更好