Plot zoom and locator in RStudio
This does not directly use RStudio's "Zoom" function, but gets pretty close at what you're probably after:
df <- data.frame(1:4)windows()plot(df)locator(1)
A couple of notes:
- You can't dynamically resize the window. If you want to zoom in, you first need to call
windows()
, then resize the window, then executeplot(df)
. - Be careful to specify the
n
argument forlocator()
. Otherwise it will crash your R session because of this bug. (Which hasn't been resolved AFAIK)
But if your purpose is to be able to use locator()
on a zoomed version of a plot (i.e. if you have a very crowded plot), this should do the trick.