Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm loading in the florentine dataset using the code below and trying to visualise the network:

library("ergm")
data("florentine")
require(intergraph)
require(igraph)
marriages <- asIgraph(flomarriage)

# Calculate degree centrality
V(marriages)$degree <- degree(marriages)

# Plot
plot(marriages, 
     vertex.label.cex = .6, 
     vertex.label.color = 'blue')

Result:

Network

Question: the nodes have numbers, not the names of the families that exist in the data set (called vertex.names). How can I replace the node numbers with the names? E.g. is there a label function I could use?

question from:https://stackoverflow.com/questions/66050638/how-to-add-label-to-simple-network-plot-in-r-code-provided

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
144 views
Welcome To Ask or Share your Answers For Others

1 Answer

# ?igraph.plotting
plot(marriages, vertex.label = V(marriages)$vertex.names)

The argument is documented on the page where you found the other arguments you used.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...