Print Graph Title and Legend
I would like to add a t least a title (possibly even a legend) to graph-tool figures.
I have tried to pass a matplotlib figure to the graph_draw function:
fig = plt.figure(figsize=(output_size/dpi, output_size/dpi), dpi=dpi)
fig.text(0.8,0.8,"Science", ha="center", va="bottom", size=vertex_number/47,color="blue")
if plot_type == "graph":
gt.graph_draw(g, pos=pos,
edge_control_points=cts,
vertex_anchor=0,
vertex_color=g.vertex_properties['vcolor'],
vertex_fill_color=g.vertex_properties['vcolor'],
vertex_font_size=14,
vertex_text=g.vertex_properties['vlabel'],
vertex_text_position=6.2,
vertex_text_rotation=g.vertex_properties['vtext_rotation'],
vertex_text_color=g.vertex_properties['vtext_color'],
vertex_size=16,
edge_start_marker="none",
edge_mid_marker="none",
edge_end_marker="none",
edge_gradient=g.edge_properties["egradient"],
eorder=g.edge_properties["eorder"],
bg_color=[1,1,1,1],
output_size=[output_size,output_size],
output="/home/chymera/graphtool.pdf",
fit_view=view_zoom,
mplfig=fig,
)
plt.savefig("/home/chymera/graphtool_fig.pdf")
The full code can be found on GitHub.
Sadly, this produces a distorted (inside-out), incorrectly scaled figure, whose sides are cropped by axes. You can see it here. The figure outputted by the graph_draw()
function looks like this.
I would like to know how I can best place text onto the graph figure as outputted by the graph_draw()
function.
The file I am showing here is but a testing example, my prospective graphs are considerably larger, so any sort of interactive editing of the produced pdf would be impossible.