使用 pyplot 關閉當前活動數字

matplotlib 的 pyplot 介面可能是關閉數字的最簡單方法。

import matplotlib.pyplot as plt
plt.plot([0, 1], [0, 1])
plt.close()