Skip to content

Shortcut for closing all figures #16863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,10 @@ This behavior is consistent with other figure saving methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is consistent with other signature mismatch errors. Previously a
ValueError was raised.

Shortcut for closing all figures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shortcuts for closing all figures now also work for the classic toolbar.
There is no default shortcut any more because unintentionally closing all figures by a key press
might happen too easily. You can configure the shortcut yourself
using :rc:`keymap.quit_all`.
2 changes: 1 addition & 1 deletion doc/users/navigation_toolbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Zoom-to-rect **o**
Save **ctrl** + **s**
Toggle fullscreen **f** or **ctrl** + **f**
Close plot **ctrl** + **w**
Close all plots **shift** + **w**
Close all plots *unassigned*
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse
Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,7 @@ def key_press_handler(event, canvas, toolbar=None):
zoom_keys = rcParams['keymap.zoom']
save_keys = rcParams['keymap.save']
quit_keys = rcParams['keymap.quit']
quit_all_keys = rcParams['keymap.quit']
grid_keys = rcParams['keymap.grid']
grid_minor_keys = rcParams['keymap.grid_minor']
toggle_yscale_keys = rcParams['keymap.yscale']
Expand All @@ -2345,6 +2346,8 @@ def key_press_handler(event, canvas, toolbar=None):
# quit the figure (default key 'ctrl+w')
if event.key in quit_keys:
Gcf.destroy_fig(canvas.figure)
if event.key in quit_all_keys:
Gcf.destroy_all()

if toolbar is not None:
# home or reset mnemonic (default key 'h', 'home' and 'r')
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ def _convert_validator_spec(key, conv):
'keymap.zoom': [['o'], validate_stringlist],
'keymap.save': [['s', 'ctrl+s'], validate_stringlist],
'keymap.quit': [['ctrl+w', 'cmd+w', 'q'], validate_stringlist],
'keymap.quit_all': [['W', 'cmd+W', 'Q'], validate_stringlist],
'keymap.quit_all': [[], validate_stringlist], # proposed values: 'W', 'cmd+W', 'Q'
'keymap.grid': [['g'], validate_stringlist],
'keymap.grid_minor': [['G'], validate_stringlist],
'keymap.yscale': [['l'], validate_stringlist],
Expand Down
2 changes: 1 addition & 1 deletion matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@
#keymap.save: s, ctrl+s # saving current figure
#keymap.help: f1 # display help about active tools
#keymap.quit: ctrl+w, cmd+w, q # close the current figure
#keymap.quit_all: W, cmd+W, Q # close all figures
#keymap.quit_all: # close all figures
#keymap.grid: g # switching on/off major grids in current axes
#keymap.grid_minor: G # switching on/off minor grids in current axes
#keymap.yscale: l # toggle scaling of y-axes ('log'/'linear')
Expand Down