How to keep camera orientation fixed in an interactive 3D plot in R/Shiny - r

I have a 3D rgl plot that users can modify based on some inputs (you can see it in action at https://magalab.shinyapps.io/rgl_test/). But every time the user modifies the input settings, renderer returns to the initial orientation to redraw the model. I want to keep the orientation consistent between updates. I know how to do that in rgl, and there is already another similar question
(Shiny RGL Plot3D: Keep Plot View Orientation On Replot), which did not receive any answer.
There is potentially a relevant topic at shiny app rglwidget get userMatrix to generate another plot with same rotation, but I don't want to see the userMatrix, simply pass it to the open3d().
Unfortunately, I am not familiar with Javascript and Shiny to achieve this. Any pointers will be much appreciated.

In the very newest rgl (version 0.99.18, currently only on R-forge), there's a function called shinyGetPar3d that is designed to do what you want. See example(shinyGetPar3d) for a demonstration of how to use it.

Related

Is it possible to show a plot in the hover info using plotly in R?

Suppose I have a plotly graph in which I want to show another plot as hover info. Is it possible using plotly or echart4r? If yes, an example would be really appreciated.
It's certainly not a straightforward solution but this should be achievable using Shiny.
Plotly has the event_data function to allow you to access information about the user's interaction with the plot (such as where they are hovering):
https://rdrr.io/cran/plotly/man/event_data.html
https://plotly-r.com/linking-views-with-shiny.html#shiny-plotly-inputs
You could then tie this to a reactive UI element which contains the plot you are after inside of a tooltip. You will likely need to use a bit of Javascript to move around the tooltip. See example 3 from here for an idea:
https://stackoverflow.com/a/38919892/2947600
Give this a go if you'd like and if you're having a hard time, I might have the time to make a minimal example.

How to implement interactive graph from plotly in overleaf?

I want to implement interactive graph from plotly in overleaf. However, overleaf removed the communication with plotly in the V2 version. Is it still possible somehow to implement interactive graph in overleaf and therefore in pdf?
I want to hide/unhide line, zoom in and see value of different points when clicking on it.
I saw this question a couple times before, but the answere was only to zoom in or use javascript and implementing different picture on top of eachother.
However, this is not what i am looking for. I am looking for a really interactive in PDF. Does somebody know how this is possible?

Manually Drawing Curves on R like Paint

I was trying to allow the user to give a curve as input for some analysis. Is there a package that can be used in this regard? Basically, a GUI like paint wherein the user can draw a simple curve and which would be stored in R as a set of data points or as an equation if its a simple curve.
Thanks
Gopher
Reading mouse input
Below is a list of sample approaches to first the problem, from the most complex to simplest (IMHO).
I would recommend that you have a look at the
qtpaint
package.
Less laborious solution may involve looking at the way interactive
plots in Shiny are handled. Using the click option would
enable you to get the mouse cursor position. Together with the Shiny
framework this would provide a convenient wrapper to get mouse input
from a user.
Finally, third approach could rely on making use of the locator function available in the graphics package. Depending on what you intend to do, this may be the simplest solution as you could then use read values to inform generation of your graphic.
Generating graphics
Assuming that you got your values via the locator functionality you could attempt to draw your line using segments. It would be a little fiddly as you would have to translate your coordinates to some placement of the dot in your desired chart but this wouldn't computationally too taxing, just a matter of bring mouse pointer values to some x/y values on the chart.
If you care to update your post with a sample code and reproducible attempts of your previous work, I bet the question will receive more replies. You may find this discussion on making a reproducible example in R helpful.

In R / gwidgets, how to create a new Widget from Scratch - links between boxes / nodes?

I want to have an interface that allows to draw links between boxes and save the results (box1 is connected to box2, 3 to 4 and so on) as shown in the picture below:
I do not really know where to start or even if something like this already exists or if it is possible - so I am grateful for any comment on the subject?
The HTkIdentify function in the TeachingDemos package allows you to interactively drag labels to new locations (and part of the return is the coordinates of the new locations) with a line between the point and the label. Visually I think this is similar to what you are asking for. It uses the tcltk package rather than gwidgets. You could modify the code to draw your boxes as above (rather than a data based scatterplot), then based on the final locations of the "labels" you would determine which box was connected to.

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

I would like to know if R allows to pan and zoom images produced with 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.

Resources