From 26ffec1555cfdaa8443932596a1525becbacb312 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 30 May 2019 13:54:30 +0200 Subject: [PATCH] Simplify removal of figure patch from bbox calculations. The in_layout property is there exactly for that purpose, so let's use it. --- lib/matplotlib/figure.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index d71f1c77968c..abcdb488215a 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -363,9 +363,10 @@ def __init__(self, self.transFigure = BboxTransformTo(self.bbox) self.patch = Rectangle( - xy=(0, 0), width=1, height=1, + xy=(0, 0), width=1, height=1, visible=frameon, facecolor=facecolor, edgecolor=edgecolor, linewidth=linewidth, - visible=frameon) + # Don't let the figure patch influence bbox calculation. + in_layout=False) self._set_artist_props(self.patch) self.patch.set_antialiased(False) @@ -2339,9 +2340,6 @@ def get_default_bbox_extra_artists(self): for ax in self.axes: if ax.get_visible(): bbox_artists.extend(ax.get_default_bbox_extra_artists()) - # we don't want the figure's patch to influence the bbox calculation - if self.patch in bbox_artists: - bbox_artists.remove(self.patch) return bbox_artists def get_tightbbox(self, renderer, bbox_extra_artists=None):