How to create a network diagram with tooltips: igraph, ggraph, networkD3? - r

This question is a followup to ggraph make filled arrow edges appear in legend (solved), but now I would like to add dynamic tooltips to the nodes to be able to show more information than can be done in a static image.
All the data, what I've tried so far & my R code is in this Rpubs document: https://rpubs.com/friendly/EDA-network
The script can be downloaded with the "code </>" button: https://rstudio-pubs-static.s3.amazonaws.com/912944_f40ed4eb53a242268ef57b7329d21d64.html#
Here is the network diagram I created using igraph and ggraph:
I tried using plotly::ggplotly() but most of the geoms used by ggraph are not recognized by ggplotly and all I got were points.
Here is a mockup of what I'd like to create showing a textbox tooltip when I hover over a node.
Can someone suggest either (a) how I can do this using the ggraph plot as a base or (b) a different network diagram package that could work.

Related

Multiple axes line chart in Power BI

I need a graph in Power BI that is a line graph but has more than 2 y-axes.
Each line has to have its own y-axis (own scale and color). The lines are from categories (like an ID) that need to be selectable with a slicer.
I have tried many custom graphs, but none seem to match my requirements. Plotly has functionality to build such graphs, but it is not supported in the python visual and it does not work in the R visual. I tried the plotly.js visual with the https://github.com/plotly/react-chart-editor editor. I could build the right graph but for each "trace" I had to manually filter out the ID's of the separate lines, instead of doing it with a slicer.
Quick attempt with plotly.js in Power BI looks like this:
I'd rather avoid writing my own custom visual, but any advice or tips are welcome.

Overlay plot on map background in R

I want to make a windrose plot on a specific location. Windrose can be plot with openair package
library(openair)
windRose(mydata, "ws", "wd")
or with ggplot using this function. What I am looking for, a nice way to overlay this plot on a map. I tried with ggmap (I don't have a google map API key) and leaflet. This example also I tried, the output is below.
Is there a way to overlay ggplot on leaflet map or any other ggmap way to do it nicely.
That is a multi-step process and will take a bit of tweaking to make it work the way you want but it can be done in 3 steps.
Set the background of your chart to transparent
Save a png locally
Use addLogo() from mapview package to post the image to your map and place it
For sure you will need to problem solve some as you implement this process. If you are doing this in Shiny you would want to use directory management to create and destroy the plots as data updates and be sure to make the creation of the graph reactive or observed in some way.
If you are making a nice rMarkdown dashboard, just make sure you keep track of where the png file saves and use the proper addressing.

how to convert a graph from visNetwork to plotly

I want to know if there is any possibility to convert a visNetwork graph to plotly graph.
The visNetwork object has an element called x, which stores nodes, edges and some other information. Using that, you could - in theory - rebuild the graph using plotly.

Is there a way to recover a ggplot2 image from a Plotly image?

I have some code that generates a plotly image in R. Previously I included this plot in a presentation using Rstudio/ioslides. The people I am collaborating with want a version in powerpoint. I am trying to use the ReporterRs package in order to create an re-producible shell powerpoint presentation with all of my plots. However ReporterRs only accepts lattice, ggplot2, and base images. Since there is a way to convert ggplot2 objects to plotly images I was hoping there was a way to go backwards. However I am stuck. I have been unable to "downgrade" my plotly plots to ggplot2. Does anyone know if there is a way to do this?
(I know I can just copy and paste them over but I would like to develop a workflow where I can create easily reproducible and replaceable plots so that I don't have to do very much work if I change the data)

Non-interactive GoogleVis charts

Is it possible for googleVis Package from R to generate Images as oppose to interactive charts? To create a GoogleVis Chart in R:
library(googleVis)
M <- gvisMotionChart(Fruits, "Fruit", "Year")
plot(M)
This initiates a browser and then it will plot an interative chart. Is there a way such that I can create a non-interactive image and plot it in R
What I have done is a complete hack, but it works. I view the HTML for the googleVis object generated and extract the svg. I save the svg as a file and open it in an image editor that can open and convert svg files.
There's no real need to use googleVis for this. If you create your plot in ggplot2, the ggthemes add-on package has theme_gdocs(), and associated colour palettes that will let you style your chart exactly like a Google Chart.
It looks like the only way to do this is to make the interactive plot, and take a screenshot. The object returned by googleVis is a Flash application embedded in html, I think you probably cannot expect it to give a static plot!
Some hacks I found that could potentially be able to convert gvis charts to images:
http://html2canvas.hertzen.com/
https://gist.github.com/battlehorse/1333906

Resources