如何在 R 中为简单网络图添加标签?提供的代码
How to Add Label to Simple Network Plot in R? Code Provided
我正在使用以下代码加载佛罗伦萨数据集并尝试可视化网络:
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')
结果:
Network
问题:节点有编号,而不是数据集中存在的家族名称(称为vertex.names
)。如何用名称替换节点号?例如。有我可以使用的标签功能吗?
# ?igraph.plotting
plot(marriages, vertex.label = V(marriages)$vertex.names)
该参数记录在您找到所用其他参数的页面上。
我正在使用以下代码加载佛罗伦萨数据集并尝试可视化网络:
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')
结果:
Network
问题:节点有编号,而不是数据集中存在的家族名称(称为vertex.names
)。如何用名称替换节点号?例如。有我可以使用的标签功能吗?
# ?igraph.plotting
plot(marriages, vertex.label = V(marriages)$vertex.names)
该参数记录在您找到所用其他参数的页面上。