Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

standard key for closing figure ("q") #830

Closed
birkenfeld opened this Issue · 3 comments

2 participants

@birkenfeld

For consistency with other plotting programs (such as gnuplot), I would love to have "q" as a standard key for closing a figure window.

@pelson
Collaborator

I have a little recipe for you which does what you want.

import matplotlib.pyplot as plt

plt.plot(range(10))

def quit_figure(event):
    if event.key == 'q':
        plt.close(event.canvas.figure)

cid = plt.gcf().canvas.mpl_connect('key_press_event', quit_figure)

plt.show()

Obviously, this doesn't give you what you asked for on all plots...

@birkenfeld

Yes, I'm already doing that for most larger scripts where it doing the work feels justified. It would just be nice to have it by default.

@pelson
Collaborator

Fixed in #851, by default you can now close a figure with "ctrl+w" on most backends.

@pelson pelson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.