diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 90f747522a39..5acac2257920 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2511,7 +2511,9 @@ class NavigationToolbar2(object): ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'), (None, None, None, None), ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'), + ('Tight', 'Tighten the layout', 'subplots', 'tight_layout'), ('Save', 'Save the figure', 'filesave', 'save_figure'), + ) def __init__(self, canvas): @@ -2568,6 +2570,11 @@ def home(self, *args): self.set_history_buttons() self._update_view() + def tight_layout(self, *args): + """Trigger a tight_layout operation.""" + self.canvas.figure.tight_layout(self.canvas.get_renderer()) + self.draw() + def _init_toolbar(self): """ This is where you actually build the GUI widgets (called by