Is it possible to show a plot in the hover info using plotly in R? - 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.

Related

How to check if a plot is visible under a tab panel?

I am working on data visualization with R and shiny.
It takes some time to load my visualization and be able to provide plots under tab panels.
Ex. I made 3 tabs for box plot, bar plot, and bean plot
Taking time to visualize the result is understandable, but I am not sure how to check if the plot is visible so that users do not need to wait even though incProcess function reports the program is done.
First, I recorded the time to visualize and tried to delay some time, but it is very subjective to the data input, so I do not think that is a good solution.
Would you be able to provide me solution?
Thank you
I think I need a solution NOT to check if a code is done but the visualization is done.

plot panel visualization using ggplot2 in R shiny

I am implementing a R shiny with a plot panel implemented by library(ggplot2). If there are 12 plots, the layout looks great. Please check below.
12-plot layout
However, if I increase the plot number to 70, then each plot looks being compressed (pls see below). Is that possible I can keep the size of each plot fixed? Thank you so much!
enter image description here
Is there another way to approach this? For instance, can you group your data by two categorical variables and use on for colouring and the other for facetting? In that way, you may be able to reduce the number of facets, and stick with the larger facet size, while still conveying all relevant information? 70 facet plots is a lot!
Is this more of a QC thing? For QC, I tend to break it into groups by condition as Paul was suggesting. The reason is that within a condition, things should be really similar. Outside a condition, all bets are off. When I do this for genomics data, I tend to use “pairs” customized to my liking.
What don’t you like about the 70 sample display? Simply the change in aspect ratio? IMO, these are the things I don’t like about ggplot. You can make these plots using base R and then place them on a page manually using par or layout. For that matter, you can do the same with ggplot and use ggarrange or a different manual layout function to place the plots. All wrapped in a for or apply of course.
The other things I like to do when I have a LOT of QCs to look through is create a movie. I can use the forward/back buttons and go through a lot quickly. I like the idea of having this in a dashboard, nice one!
you could also try coord_fixed(ratio= ), not sure if that will work with faceting or not
Finally, I have made a movie-like visualization for those 70 plots using the plot_ly function in R package "plotly".

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?

R: interact with customized XML map

A Stack Overflow discussion here (How to make a heat map in R based on a gif of the human body?) describe how to plot a map for different part of human body in R.
I want to make the plot more interactive, i.e. if I move the cursor to the torso, I want to see a message "torso".
In other words, what I want to do is similar to the "identify" function for scattor plot, but is for plots generated from XML.
Another example for what I would like to achieve is: https://plot.ly/r/choropleth-maps/
Thanks!

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.

Resources