user6131384
user6131384

Reputation:

Plot network using ggnet2

I have a network that I created by importing a gml file. If I plot this network using plot, nodes have the correct label (string). If I try to do the same thing using ggnet2, the labels become numbers. Why? This is my code:

   library(igraph)
   library(poweRlaw)
   library(sna)
   library(ggplot2)
   library(GGally)
   library(ergm)
   library(intergraph)

   net <- read.graph("./network.gml", format = c("gml"))

plot(net) netb <- asNetwork(net) ggnet2(netb, size = "degree", label = TRUE)

The results I get are: enter image description here enter image description here

Upvotes: 1

Views: 1345

Answers (1)

Mekki MacAulay
Mekki MacAulay

Reputation: 1727

Without seeing your data, it's most likely that read.graph is setting the vertex names to be numbers and that plot is grabbing the names from a different variable. The ggnet2 documentation explains that the label variable can be set to the name of the vertex attribute that you wish to use. Try changing label = TRUE to label="<VertexName>" where <VertexName>is the name of the vertex in netb that contains the labels.

Upvotes: 1

Related Questions