You are reading an old version of the documentation (v1.4.1). For the latest version see https://matplotlib.org/stable/
matplotlib

Previous topic

event_handling Examples

Next topic

event_handling example code: data_browser.py

This Page

event_handling example code: close_event.pyΒΆ

[source code]

from __future__ import print_function
import matplotlib.pyplot as plt

def handle_close(evt):
    print('Closed Figure!')

fig = plt.figure()
fig.canvas.mpl_connect('close_event', handle_close)

plt.text(0.35, 0.5, 'Close Me!', dict(size=30))
plt.show()

Keywords: python, matplotlib, pylab, example, codex (see Search examples)