0

I want to assign a igraph plot to a variable and use it later. But I found that I cannot assign it.

for instance, with the following code, p returns NULL.

How can I assign the igraph plot object?

library(igraph)
mat <- cor(mtcars)
mat[mat<0.6] <- 0
network <- graph_from_adjacency_matrix(mat, weighted=T, mode="undirected", diag=F)
p = plot(network)
p
Wang
  • 940
  • 8
  • 17
  • 3
    That's correct. `igraph` uses base R graphics which do not return any values and have the side effect of drawing to the graphics device. What are you hoping to do with the plot in a variable? You could try methods suggested here https://stackoverflow.com/a/29583945/2372064 like `recordPlot()` to capture base graphics plots as variables. But you are still somewhat limited with what exactly you can do with it. – MrFlick Mar 10 '22 at 23:40

0 Answers0