8000 ENH: add figure.legend_outside · matplotlib/matplotlib@20a56fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 20a56fb

Browse files
committed
ENH: add figure.legend_outside
1 parent 19935d6 commit 20a56fb

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

lib/matplotlib/figure.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,6 @@ def add_subplot(self, *args, **kwargs):
14181418
# more similar to add_axes.
14191419
self._axstack.remove(ax)
14201420

1421-
14221421
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
14231422

14241423
return self._add_axes_internal(key, a)
@@ -1926,7 +1925,7 @@ def legend_outside(self, *, loc=None, axs=None, **kwargs):
19261925
return leg
19271926

19281927
if loc is None:
1929-
loc = 1 # upper right
1928+
loc = 1 # upper right
19301929

19311930
if axs is None:
19321931
gs = self.get_gridspecs()[0]

lib/matplotlib/gridspec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def legend_outside(self, handles=None, labels=None, axs=None, **kwargs):
185185
if not (self.figure and self.figure.get_constrained_layout()):
186186
cbook._warn_external('legend_outside method needs '
187187
'constrained_layout')
188-
leg = self.figure.legend(*args, **kwargs)
188+
leg = self.figure.legend(**kwargs)
189189
return leg
190190

191191
if axs is None:
@@ -197,7 +197,6 @@ def legend_outside(self, handles=None, labels=None, axs=None, **kwargs):
197197
paddingw = padding / self.figure.get_size_inches()[0]
198198
paddingh = padding / self.figure.get_size_inches()[1]
199199

200-
201200
handles, labels, extra_args, kwargs = legend._parse_legend_args(
202201
axs, handles=handles, labels=labels, **kwargs)
203202
leg = LegendLayout(self, self.figure, handles, labels, *extra_args,
@@ -395,13 +394,13 @@ def tight_layout(self, figure, renderer=None,
395394
self.update(**kwargs)
396395

397396

398-
399397
class LegendLayout(legend.Legend):
400398
"""
401399
`.Legend` subclass that carries layout information....
402400
"""
403401

404-
def __init__(self, parent, parent_figure, handles, labels, *args, **kwargs):
402+
def __init__(self, parent, parent_figure, handles, labels, *args,
403+
**kwargs):
405404
super().__init__(parent_figure, handles, labels, *args, **kwargs)
406405
self._layoutbox = layoutbox.LayoutBox(
407406
parent=parent._layoutbox,
@@ -412,7 +411,8 @@ def _update_width_height(self):
412411

413412
invTransFig = self.figure.transFigure.inverted().transform_bbox
414413

415-
bbox = invTransFig(self.get_window_extent(self.figure.canvas.get_renderer()))
414+
bbox = invTransFig(
415+
self.get_window_extent(self.figure.canvas.get_renderer()))
416416
height = bbox.height
417417
h_pad = 0
418418
w_pad = 0

lib/matplotlib/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def __init__(self, parent, handles, labels,
484484
self.axes = parent
485485
self.set_figure(parent.figure)
486486
elif isinstance(parent, GridSpec):
487-
self.isaxes=False
487+
self.isaxes = False
488488
self.set_figure(parent.figure)
489489
elif isinstance(parent, Figure):
490490
self.isaxes = False

0 commit comments

Comments
 (0)
0