Reputation: 11803
I'm using r package igraph and threejs to visualize my network. Here is an example to show the issue I found.
# Make a correlation matrix:
mat=cor(t(mtcars[,c(1,3:6)]))
# Keep only high correlations
mat[mat<0.995]=0
# Make an Igraph object from this matrix:
net=graph_from_adjacency_matrix( mat, weighted=T, mode="undirected", diag=F)
graphjs(net)
what I got is a blank picture. I also tried to use igraph2graphjs function to convert igraph object to convert it to graphjs friendly object. But it seems like there is no such function from threejs package any more.below is the error message I got.
net.js <- threejs::igraph2graphjs(net)
graphjs(net.js)
Error: 'igraph2graphjs' is not an exported object from 'namespace:threejs'
A follow-up question is: Is there any other package I can use to make interactive visualization from igraph objects?
Upvotes: 0
Views: 460
Reputation: 2022
With current version 0.3.1
you can pass the igraph
object to the graphjs
function. The issue still persists until you set the vertex attributes.
Setting the vertex attributes size
and color
should solve the problem
g <- graph_from_data_frame(df)
V(g)$size <- 10
V(g)$color <- 'red'
graphjs(g)
Upvotes: 0
Reputation: 1847
graphjs
output needs to be rendered in the outside viewer.
If you run the code in the R
terminal interpreter it works like a charm.
Somehow RStudio
does not handle it automatically. Try to use the: Show in new window option in the Viewer
panel of the RStudio
. It opens your graph externaly (e.g. in the web browser).
Upvotes: 1