简体   繁体   English

在RStudio中绘制缩放和定位器

[英]Plot zoom and locator in RStudio

Is there a way to enable locator() functionality in the RStudio plot zoom? 有没有办法在RStudio情节缩放中启用locator()功能? 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: 这仅适用于RStudio的较小窗口(默认右下角),但是当您单击已作为单独窗口打开的查看器时,不会捕获任何坐标:

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. 我正在使用RStudio版本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: 这并不是直接使用RStudio的“缩放”功能,而是非常接近你可能会追求的东西:

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) . 如果要放大,首先需要调用windows() ,然后调整窗口大小,然后执行plot(df)
  2. Be careful to specify the n argument for locator() . 注意为locator()指定n参数。 Otherwise it will crash your R session because of this bug. 否则会因为这个错误而导致R会话崩溃 (Which hasn't been resolved AFAIK) (尚未解决的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. 但是如果你的目的是能够在一个缩放版本的情节上使用locator() (即如果你有一个非常拥挤的情节),这应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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