【发布时间】:2016-05-15 04:34:16
【问题描述】:
我需要处理 pyplot 对象,例如图形和轴。这是我想要的一个简化示例:
In [1]: import matplotlib.pyplot as mp
In [2]: fig = mp.figure() # create a figure
In [3]: mp.show() # and immediately show it. And close.
In [4]: ax = fig.add_subplot(111) # Then I create a plot on that figure
In [5]: ax.plot([1, 2, 3])
Out[5]: [<matplotlib.lines.Line2D at 0x104e29a50>]
In [6]: mp.get_fignums() # But I already released the figure, so it doesn't appear in the list of available figures
Out[6]: []
In [7]: fig.axes[0].lines[0].get_data() # The data is there, on the plot
Out[7]: (array([ 0., 1., 2.]), array([1, 2, 3]))
In [8]: mp.show() # But mp.show() shows nothing.
fig.show() 也不起作用。释放后如何显示图形?
UPD:有一个类似的问题:Matplotlib: re-open a closed figure?,但没有答案。
【问题讨论】:
-
为什么不从一个有效的
matplotlib示例开始? -
我很高兴有一个显示它的工作示例,如何获取已发布的数字。
标签: python matplotlib