使用python和matplotlib的多图(不是子图)

时间:2017-01-28 01:04:59

标签: python matplotlib graph

我想使用pythonmatplotlib一次绘制两个或更多图表。我不想使用子图,因为它实际上是在同一张图纸上的两个或多个图。

有什么办法吗?

1 个答案:

答案 0 :(得分:-1)

您可以使用多个数字并在每个数字中绘制一些数据。最简单的方法是调用plt.figure()并使用pyplot statemachine。

import matplotlib.pyplot as plt

plt.figure() # creates a figure
plt.plot([1,2,3])

plt.figure() # creates a new figure
plt.plot([3,2,1])

plt.show() # opens a window for each of the figures

如果出于任何原因创建第二个数字后你想要绘制第一个数字,你需要通过

“激活”它
plt.figure(1)
plt.plot([2,3,1]) # this is plotted to the first figure.

(图号从1开始)