Matplotlib人物复活后不关闭

2024-09-24 12:31:13 发布

您现在位置:Python中文网/ 问答频道 /正文

请尝试以下代码:

import matplotlib.pyplot as plt
fig = plt.figure() #creates a pyplot figure
plt.close(fig) #closes the figure
fig.show() #resurrects the figure, that is, displays it
plt.close(fig) #should close the figure, but does nothing

我的问题是:

  1. 为什么最后一行代码不关闭图形?

  2. 如何得到关闭的数字无论如何(编程)后,它已经复活如上所述?


Tags: the代码importclosethatmatplotlibasshow