From 620fa8f9133bd7c8a364fce9457243cdee42cdc4 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Wed, 18 Jul 2012 23:45:04 -0500 Subject: [PATCH] New button to toolbar for tight_layout. - Need a new icon! --- lib/matplotlib/backend_bases.py | 7 +++++++ 1 file changed, 7 insertions(+) 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