简体   繁体   中英

Plot zoom and locator in RStudio

Is there a way to enable locator() functionality in the RStudio plot zoom? This only works in the smaller window (default bottom right) of RStudio but when you click on a viewer already open as a separate window, no coordinates are captured:

plot(iris$Petal.Width, iris$Petal.Length)
locator()

Perhaps the answer here is that is not currently implemented and that is why I couldn't find mention of it online.

I'm using RStudio version 0.99.491.

Thanks in advance.

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:

  1. You can't dynamically resize the window. If you want to zoom in, you first need to call windows() , then resize the window, then execute plot(df) .
  2. Be careful to specify the n argument for locator() . 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 (ie if you have a very crowded plot), this should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM