【问题标题】:multiple graph (not subplot) using python and matplotlib使用 python 和 matplotlib 的多个图(不是子图)
【发布时间】:2017-01-28 01:04:58
【问题描述】:

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

有什么办法吗?

【问题讨论】:

  • matplotlib.pyplot.figure() 将为您打开一个新的图形窗口,如果您是这个意思。
  • 您总是可以通过使用figsize=(width,height)matplotlib.pyplot.figure() 内指定宽度和高度(以英寸为单位),然后使用子图来使您的图形更大。
  • @WKK 我认为您所说的“在同一张绘图纸上绘制两个或多个绘图”并不明确。您可以编辑问题以更清楚地解释您要做什么吗?

标签: python matplotlib graph


【解决方案1】:

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

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开始)

【讨论】:

    猜你喜欢
    • 2015-10-24
    • 2016-09-18
    • 2018-09-28
    • 2015-10-20
    • 1970-01-01
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    相关资源
    最近更新 更多