5

我在 Python 3.5.1 上使用图形工具。我有一个单词图,单词之间有押韵的边缘。当我使用graph-tool的draw功能时,如果我将顶点设置得太大,会导致所有顶点重叠,但是如果它们太小,我必须将字体变小,然后它就难以辨认。有没有办法设置最小边长或强制顶点不重叠?

代码示例:

import graph_tool.all as gt

G = gt.load_graph("G.gt")
gt.graph_draw(G, vertex_text=G.vertex_properties.word, vertex_font_size=10, output_size=(1000, 1000), output="G.png", vertexsize=10)

在此处查看图片

4

2 回答 2

1

我的猜测是你不能改变边缘的相对大小,但你可以改变字体和顶点大小。所以目前我正在缩小顶点并在它们之外显示文本。工作精美。

import cairo
from graph_tool.draw import graph_draw, prop_to_size

graph_draw(g, 
       edge_pen_width=1,
       vertex_text=g.vp.my_property, 
       vertex_aspect=1, 
       vertex_text_position=1, 
       vertex_text_color='black',
       vertex_font_family='sans',
       vertex_font_size=11,
       vertex_font_weight=cairo.FONT_WEIGHT_NORMAL,
       vertex_color=None,
       vertex_size=5
      )
于 2018-12-14T05:39:23.843 回答
1

Have you tried using graphviz_draw? It has an overlap setting where you can tell the software to prevent vertices from touching. The syntax is different for the function so you may need to do some searching but if you look at the graphviz documentation linked in the graph-tool manual you should be able to find all your attributes (http://www.graphviz.org/doc/info/attrs.html ).

于 2017-02-06T15:25:30.600 回答