简体   繁体   中英

How to plot graph in time series

I have a list of igraph instance in time series.

[<igraph.Graph object at 0xbae0f2c>, <igraph.Graph object at 0xb67e12c>, <igraph.Graph       object at 0xb67e0ac>, <igraph.Graph object at 0xb67e02c>, <igraph.Graph object at 0xb67e1ac>, <igraph.Graph object at 0xb67e22c>, <igraph.Graph object at 0xb67e2ac>, <igraph.Graph object at 0xb67e32c>]

I can plot them one by one using:

import igraph as ig
for graph in dgs._visualize_raw:
    layout=graph.layout("kk")
    ig.plot(graph,layout=layout)

How can I plot them in time series together in one picture?

Create a Plot object and add the graphs to them one by one. Eg:

graphs = [Graph.GRG(10, 0.4) for _ in xrange(5)]
figure = Plot(bbox=BoundingBox(0, 0, len(graphs)*200, 200))
for i, graph in enumerate(graphs):
    figure.add(graph, bbox=BoundingBox(i*200, 0, (i+1)*200, 200), margin=20)
figure.show()            # this will show the figure
figure.save("test.pdf")  # this will save the figure into a PDF file; JPG, PS and SVG are also supported

Actually, the plot command does the same thing in the background: it creates a figure, adds the object being plotted to the figure and then shows or saves it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM