备注
Go to the end 下载完整示例代码..
关闭事件#
示例展示了当图像关闭时发生的连接事件.
备注
此示例练习 Matplotlib 的交互功能,这不会出现在静态文档中.请在您的机器上运行此代码以查看交互性.
您可以复制和粘贴各个部分,或者使用页面底部的链接下载整个示例.

import matplotlib.pyplot as plt
def on_close(event):
print('Closed Figure!')
fig = plt.figure()
fig.canvas.mpl_connect('close_event', on_close)
plt.text(0.35, 0.5, 'Close Me!', dict(size=30))
plt.show()