top of page

Making Interactive Network Plots in R

Recently I have dedicated some time to creating a custom function (intPlot) to generate interactive psychometric network plots in R. My inspiration (and some of the function code) for this came from the dynamic.plot function from the EGAnet package in R (Golino & Demetriou, 2017). Although the project I am working on that will use these plots has not yet been published, I found this to be really fun and informative, especially for explaining things to folks who are still kind of new to network analysis.

​

The R code for intPlot will take some work on the user's part, but it isn't too bad if you're familiar with R and I've made a good deal of comments in the scripts linked below. I will continue to refine this into a less-clunky form as I am able (probably once my dissertation is done!).

​

Below are a few examples of different possibilities of this script using the bfi data from the psych package. Please note that these will likely not display properly on mobile devices.

​

To zoom in on any part of the plot just click and drag your mouse as if you were selecting a collection of desktop icons; double click to zoom back to the default view.

Example 1: Constant node size - cursor hover displays item content, strength centrality, and bridge centrality (2-step). R code for this example.  R code for this exact plot without bridge centrality is available here.

Example 2: Dynamic node size - size of nodes indicates their degree of bridge centrality relative to others in the network. Notice that the nodes are now slightly transparent - this is necessary when using dynamic sizing because the larger nodes (e.g., ) will obscure large portions of the edges. R code for this version available here.

Example 3: Nodes are still dynamic in size, but I've changed to strength centrality estimates for node sizes. This time I've also added a custom annotation providing general information about the network. R code for this example available here.

That's going to do it for now! Thanks for reading.

 

Check back for updates as I am able to post them or follow me on Twitter - @SamuelJamesWest

bottom of page