相信很多菜鸟都有和我一样的问题:每次使用plot()作图的时候,前面做的图总是会被覆盖掉,这样非常麻烦,如果想要比较一下的话很麻烦。
根据前面使用matlab的经验看,每次作图之前使用figure()函数就会出来一个新的画图框;这里r语言也是一样的,只需在每次作图之前使用一下windows()
命令就行了。
虽然这些小事情看起来简单,不过还是可以慢积累的。
参考代码:
cars <- c(3, 2, 3, 4, 3)
plot(cars, type = "o", pch = 22, col = "red",
main = "Fig.1", xlab = "Time", axes = F)
axis(side = 1, at = 1:5, lab = c("Mon", "Tue", "Wen", "Thi", "Fri"))
axis(side = 2)
#plot a new figure
windows()
truck <- c(4, 2.5, 3, 4.5, 3)
plot(truck, type = "o", pch = 15, col = "blue",
main = "Fig.2", xlab = "Time", axes = F)
axis(side = 1, at = 1:5, lab = c("Mon", "Tue", "Wen", "Thi", "Fri"))
axis(side = 2)
|