我有一个返回Figure创建的函数pyplot.此函数在返回之前关闭图形.如果我没有关闭它,只显示它会很容易plt.show(),但让我们假设我不能这样做.
我可以轻松地将返回Figure的文件保存到文件中,但是我找不到显示它的方法(即:有一个显示该图的弹出窗口).
from matplotlib import pyplot as plt
def new_figure():
fig = plt.figure()
plt.plot([0, 1], [2, 3])
plt.close(fig)
return fig
fig = new_figure()
fig.savefig('output.svg')
fig.show()
Run Code Online (Sandbox Code Playgroud)
我怎么能显示这个数字?