Skip to content

Commit

Permalink
Merge pull request matplotlib#16863 from timhoffm/quit-all2
Browse files Browse the repository at this point in the history
Shortcut for closing all figures
  • Loading branch information
QuLogic authored Mar 24, 2020
2 parents cf4021a + 40da397 commit 3e6c5d0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
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 @@ -2333,6 +2333,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 @@ -2349,6 +2350,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

0 comments on commit 3e6c5d0

Please sign in to comment.