Question

graph-tool for python is cutting off my edges, and I can't seem to fix it, no matter how much I hack... help! Changing the output size does nothing.

Also, my edge text looks like crud. Any suggestions?

graph_draw(g, vertex_shape = vs, vertex_text = vl, vertex_font_size = 18, edge_text = el, edge_font_size = 40, edge_text_distance = 0,
           edge_marker_size = 30, output_size = (400,400), vertex_size = 40, output = "output.png")

enter image description here

Was it helpful?

Solution

You pass the fit_view = False option to graph_draw(), it will not attempt to scale the drawing to fit the output size. You can then choose your view by changing the posions of the nodes, such that it does not exclude any part of the graph:

g = random_graph(10, lambda: 10, self_loops=True, directed=False)
pos = sfdp_layout(g)
x, y = ungroup_vector_property(pos, [0, 1])
x.a = (x.a - x.a.min()) / (x.a.max() - x.a.min()) * 200 + 100
y.a = (y.a - y.a.min()) / (y.a.max() - y.a.min()) * 200 + 100
pos = group_vector_property([x, y])
graph_draw(g, pos, output_size=(400, 400), output="foo.png", fit_view=False)

enter image description here

You can improve the edge labels by tuning the properties text_distance, text_parallel and font_size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top