Created
October 5, 2017 12:57
-
-
Save renejahn/a1016590bbcf04ba19b8357222a01876 to your computer and use it in GitHub Desktop.
close matplotlib figures via escape button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import matplotlib.pyplot as plt | |
def connect_close(figure=None): | |
def press_key(event): | |
if event.key == 'escape': | |
plt.close('all') | |
sys.exit(0) | |
if not figure: | |
figure = plt.gcf() | |
figure.canvas.mpl_connect('key_press_event', press_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!