# NOT RUN {
# }
# NOT RUN {
# basic example
plot(rnorm(1000),rnorm(1000)) # could be any plot
zm() # navigate the plot
# use the same xlim/ylim as ended up in the zoom session
xylim<-par("usr") # xmin,xmax,ymin,ymax of the final version of the plot
dev.off()
plot(rnorm(1000),rnorm(1000),xlim=xylim[1:2],ylim=xylim[3:4])
# navigate two layers of data at the same time
par(mfrow=c(1,2))
plot(1,type="n",xlim=c(-3,3),ylim=c(-3,3),main="First Track")
polygon(c(-1,1,1,-1)*2,c(-1,-1,1,1)*2,col="blue")
lines(rnorm(100),rnorm(100))
plot(1,type="n",xlim=c(-3,3),ylim=c(-3,3),main="Second Track")
polygon(c(-1,1,1,-1)*2,c(-1,-1,1,1)*2,col="green")
lines(rnorm(100),rnorm(100))
zm() # it flickers quite a bit as it needs to replot everything every time...
# one might want to use the older interface
# if attached to cairo under linux or MacOS
# it is also sometimes helpful to just define a square you want to zoom on
zm(type="s")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab