Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e02f50

Browse files
committed
Merge pull request #1617 from jenshnielsen/legend_bbox
Legend: Also calc the bbox of the legend when the frame is not drawn. (1.2.x)
2 parents 293d42b + 6f07e0b commit 5e02f50

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/legend.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ def draw(self, renderer):
460460
pad = 2 * (self.borderaxespad + self.borderpad) * fontsize
461461
self._legend_box.set_width(self.get_bbox_to_anchor().width - pad)
462462

463-
if self._drawFrame:
464-
# update the location and size of the legend
465-
bbox = self._legend_box.get_window_extent(renderer)
466-
self.legendPatch.set_bounds(bbox.x0, bbox.y0,
467-
bbox.width, bbox.height)
468-
469-
self.legendPatch.set_mutation_scale(fontsize)
463+
# update the location and size of the legend. This needs to
464+
# be done in any case to clip the figure right.
465+
bbox = self._legend_box.get_window_extent(renderer)
466+
self.legendPatch.set_bounds(bbox.x0, bbox.y0,
467+
bbox.width, bbox.height)
468+
self.legendPatch.set_mutation_scale(fontsize)
470469

470+
if self._drawFrame:
471471
if self.shadow:
472472
shadow = Shadow(self.legendPatch, 2, -2)
473473
shadow.draw(renderer)

0 commit comments

Comments
 (0)