简体   繁体   English

如何按时间序列绘制图

[英]How to plot graph in time series

I have a list of igraph instance in time series. 我按时间顺序列出了igraph实例。

[<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. 创建一个Plot对象,然后将图形一个接一个地添加到其中。 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. 实际上, plot命令在后台执行相同的操作:创建图形,将要绘制的对象添加到图形,然后显示或保存它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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