Skip to content
Closed
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 lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad my factoring has made it so easy to add a button. I can't remember if there were any backends which do not currently use this list. Probably worth checking.

('Save', 'Save the figure', 'filesave', 'save_figure'),

)

def __init__(self, canvas):
Expand Down Expand Up @@ -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
Expand Down