diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 3c9357106950..f88a04839c75 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -4155,7 +4155,18 @@ def get_default_bbox_extra_artists(self): Artists are excluded either by not being visible or ``artist.set_in_layout(False)``. """ - return [artist for artist in self.get_children() + + artists = self.get_children() + if not (self.axison and self._frameon): + # don't do bbox on spines if frame not on. + for spine in self.spines.values(): + artists.remove(spine) + + if not self.axison: + for _axis in self._get_axis_list(): + artists.remove(_axis) + + return [artist for artist in artists if (artist.get_visible() and artist.get_in_layout())] def get_tightbbox(self, renderer, call_axes_locator=True, diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 211c807eb8c6..45bbb001fc8b 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -125,6 +125,11 @@ def __init__( self.figure.add_axes(self) + # mplot3d currently manages its own spines and needs these turned off + # for bounding box calculations + for k in self.spines.keys(): + self.spines[k].set_visible(False) + def set_axis_off(self): self._axis3don = False self.stale = True