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

Skip to content

Commit 012c052

Browse files
authored
Merge pull request #12522 from meeseeksmachine/auto-backport-of-pr-12241-on-v3.0.x
Backport PR #12241 on branch v3.0.x (FIX: make unused spines invisible)
2 parents fc69f36 + 870aced commit 012c052

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4155,7 +4155,18 @@ def get_default_bbox_extra_artists(self):
41554155
Artists are excluded either by not being visible or
41564156
``artist.set_in_layout(False)``.
41574157
"""
4158-
return [artist for artist in self.get_children()
4158+
4159+
artists = self.get_children()
4160+
if not (self.axison and self._frameon):
4161+
# don't do bbox on spines if frame not on.
4162+
for spine in self.spines.values():
4163+
artists.remove(spine)
4164+
4165+
if not self.axison:
4166+
for _axis in self._get_axis_list():
4167+
artists.remove(_axis)
4168+
4169+
return [artist for artist in artists
41594170
if (artist.get_visible() and artist.get_in_layout())]
41604171

41614172
def get_tightbbox(self, renderer, call_axes_locator=True,

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ def __init__(
125125

126126
self.figure.add_axes(self)
127127

128+
# mplot3d currently manages its own spines and needs these turned off
129+
# for bounding box calculations
130+
for k in self.spines.keys():
131+
self.spines[k].set_visible(False)
132+
128133
def set_axis_off(self):
129134
self._axis3don = False
130135
self.stale = True

0 commit comments

Comments
 (0)