1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
"""
===========
Close event
===========
Example to show connecting events that occur when the figure closes.
.. note::
This example exercises the interactive capabilities of Matplotlib, and this
will not appear in the static documentation. Please run this code on your
machine to see the interactivity.
You can copy and paste individual parts, or download the entire example
using the link at the bottom of the page.
"""
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()
|