Version 3.1.2
matplotlib

Related Topics

Close EventΒΆ

Example to show connecting events that occur when the figure closes.

Traceback (most recent call last):
  File "/build/matplotlib-mO9dyQ/matplotlib-3.1.2/examples/event_handling/close_event.py", line 1
    ===========
    ^
SyntaxError: invalid syntax
===========
Close Event
===========

Example to show connecting events that occur when the figure closes.
"""
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: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery