2016-06-09 111 views
1

我試圖將使用python graph_tool庫創建的圖形輸出到PNG文件。最終的結果是繪製的圖頂點重疊。我意識到問題是當我把文本放在頂點或邊上時,就像文本框的邊距太大。graph_tool graph_draw頂點文本框邊距頂點重疊

size = 4000 
v_size = size/my_graph 
e_pwidth = v_size/10 
graph_draw(my_graph, vertex_shape='square', vertex_text=my_graph.vp.inst_str, vertex_size=v_size, output_size=(size, int(size*1.5), vertex_font_size=e_pwidth, vertex_aspect=1.5, edge_pen_width=e_pwidth, edge_text=my_graph.ep.edgelabel, output="f.png") 

它將輸出類似:

graph_tool graph_draw output graph image

看文字和頂點的邊界之間的距離,我不能去減少距離。

回答

1

我想我找到了一種方法。問題是,當你將文本屬性設置爲頂點時,它會增加頂點的大小以適應文本,但是如果將屬性vertex_text_position設置爲除-1之外的任何負值,則不會調整頂點的大小,然後就可以設置你想要的頂點的大小。