我正在尝试调整Python igraph包中边缘标签的字体大小,但是一旦我尝试添加标签大小属性,以前存在的标签就会消失。我在igraph文档中找不到关于边缘标签大小的任何信息,而且我想知道是否无法做我想做的事情。这是一些不可复制的伪代码来说明:
G = ig.Graph(directed=True)
outgoing = G.es.select(..., ...)
incoming = G.es.select(..., ...)
outgoing["label"] = ...
incoming["label"] = ...
# once I add these lines... **, the labels disappear
outgoing["label_size"] = 2
incoming["label_size"] = 3
visual_style["edge_label"] = G.es["label"]
visual_style["edge_label_size"] = G.es["label_size"]
ig.plot(G, **visual_style)
将不胜感激,如果有人知道我可能在文档中找到它的话
您做得正确,但分配的尺寸非常小。
首先绘制具有默认属性的图形,其点大小为12。
import igraph
g = igraph.Graph([(0, 1), (0, 2), (1, 2)])
g.vs["label"] = [1, 2, 3]
g.es["label"] = "edge"
layout = g.layout("fr")
igraph.plot(g, "graph_default.png", layout = layout, bbox=(200, 200))
将产生以下图像。
更改边缘标签尺寸后
g.es[0]["label_size"] = 2
g.es[2]["label_size"] = 24
layout = g.layout("fr")
igraph.plot(g, "graph_scaled.png", layout = layout, bbox=(200, 200))
这变成:
边缘几乎消失的地方。