开发者

Can I navigate, zoom in and zoom out R plots?

开发者 https://www.devze.com 2023-03-24 09:39 出处:网络
I would like to know if R allows to pan and zoom images produced wi开发者_如何学运维th the \"plot\" function. I would like to obtain the plot transformation using the mouse and not through the command

I would like to know if R allows to pan and zoom images produced wi开发者_如何学运维th the "plot" function. I would like to obtain the plot transformation using the mouse and not through the command line, is it possible?

Thanks in advance.


It's a bit old question but for future references, I've wrote a package doing precisely that (based on zoomplot {in pkg:TeachingDemos}). It's called zoom:

The CRAN page on zoom

And you are welcome to check the latest and greatest and expand the package on Github

Usage -

library(zoom) # Invoke the Library
# Call plot
zm()

The instructions for Usage in a normal plot is

Mouse:

  • Scroll to zoom in and out
  • Hold left mouse button to move

Keyboard:

  • Left/Right (h/l): move left/right
  • Up/Down (k/j) : move up/down
  • + or i / - or o : zoom in/out
  • L/H : zoom in/out (x-axis only)
  • K/J : zoom in/out (y-axis only)
  • p : print to file
  • r : reset limits
  • s : show limits

q on the graphic window to quit


Not with the default plotting device as its internal model is 'static'.

There are workarounds, tough: look for example at package playwith, or at a Java-based device such as the iplots package on Simon's rforge. There are also extensions like ggobi and other on-going work (such as the Qt-based device which will in time replace ggobi) which try to make R-based graphing more dynamic.

But the main takeaway is: not, not really -- due to the way R graphics devices are designed.


To add to Dirk's answer: see also the iWebPlots and RnavGraph packages.


You should look at Greg Snows zoomplot {in pkg:TeachingDemos}. You may be able to call that function with cursor interface using the tk toolkit. I think Greg's package also has examples of such an interface.


To add to existing answers: I like to use the identify() function to manually add labels just to particular points I want.


You can also add R graphs to plot.ly . This should be enough for the most common stuff.

Stefan


Now there are also http://www.htmlwidgets.org/ that add a great set of interactive visualizations capabilities to R. Most of them can easily be zoomed and panned.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号