https://github.com/cran/Hmisc
Raw File
Tip revision: ffaa7df0d13fef0eb7566405cc8d47eb60866db7 authored by Charles Dupont on 22 January 2009, 21:58:09 UTC
version 3.5-0
Tip revision: ffaa7df
zoom.s
## Function to use the mouse to zoom in on plots.
## Author: Bill Dunlap <bill@STAT.WASHINGTON.EDU>
zoom<-function(fun=usa,...)
{
  on.exit(par(oldpar))
  oldpar<-par(err=-1)
  fun(...)
  while(TRUE) {
    cat("Click mouse over corners of zoom area: ")
    p<-locator(n=2)
    if(is.null(p$x) || length(p$x)!=2)
      break

    xlim<-range(p$x)
    ylim<-range(p$y)
    cat("xlim=",xlim,"ylim=",ylim,"\n")
    fun(...,xlim=xlim,ylim=ylim)
  }

  cat("Bye!\n")
}
back to top