How to store images of graphs in a PDF?
I know that I can convert a single graph to PDF using the command.
s = 'J~f[MN@PQg?'
g = Graph(s, sparse=True);
g.plot(layout="planar").save("g.pdf")
I want to highlight the edges of some graphs in red and then store them separately in a PDF with different pages.
s = 'J~f[MN@PQg?'
g = Graph(s, sparse=True);
g.plot(layout="planar",save_pos=True)
g.delete_vertex(2)
H = graphs.CycleGraph(10)
L = { tuple(g.edges(labels=False,sort_vertices=True,sort=True)) for g in g.subgraph_search_iterator(H, induced=False) }
print(len(L))
cylce_lists = list(map(list, L))
def plot_with_highlight(G, highlight_edges):
highlight_vertices = list(set().union(*highlight_edges))
plot(G, edge_colors={'red': highlight_edges}, vertex_colors={'red': highlight_vertices}).show()
for highlight_edges in cylce_lists:
plot_with_highlight(g, highlight_edges)
I got six figures. My goal is to print. It would be perfect if two images could be placed on each row of a single PDF.
A couple suggestions :
You might put your figures in separate files, then merging them with an external tool such as pdftk (I use the free software version disributed by Debian).
You may want to create graphics arrays to group your figures.
HTH,
Nice. It seems that we must add return in plot_with_highlight.
Now it is ok.