Skip to content


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

birkenfeld opened this Issue · 5 comments

3 participants


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

Matplotlib Developers member

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

import matplotlib.pyplot as plt


def quit_figure(event):
    if event.key == 'q':

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

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


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.

Matplotlib Developers member

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

@pelson pelson closed this

@pelson what did you mean by "Added a close figure key ("q" by default)" ? Where did you do the modification (inside some file?) ?

Matplotlib Developers member

@pelson what did you mean by "Added a close figure key ("q" by default)" ?

All matplotlib figures can be closed with "ctrl + w" / "cmd + w" since a good number of years.

The changes (rather broadly) were done in #851. The specific file which changed:

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.