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

Skip to content

Commit 0a926aa

Browse files
committed
FIX: make unused spines invisible
FIX: remove visible logic from _base.py FIX: also exclued spines tight layout
1 parent 49480ee commit 0a926aa

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
@@ -4172,7 +4172,18 @@ def get_default_bbox_extra_artists(self):
41724172
Artists are excluded either by not being visible or
41734173
``artist.set_in_layout(False)``.
41744174
"""
4175-
return [artist for artist in self.get_children()
4175+
4176+
artists = self.get_children()
4177+
if not (self.axison and self._frameon):
4178+
# don't do bbox on spines if frame not on.
4179+
for spine in self.spines.values():
4180+
artists.remove(spine)
4181+
4182+
if not self.axison:
4183+
for _axis in self._get_axis_list():
4184+
artists.remove(_axis)
4185+
4186+
return [artist for artist in artists
41764187
if (artist.get_visible() and artist.get_in_layout())]
41774188

41784189
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
@@ -126,6 +126,11 @@ def __init__(
126126

127127
self.figure.add_axes(self)
128128

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

0 commit comments

Comments
 (0)