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

Skip to content

Commit d530e47

Browse files
committed
Only consider visible Axises in Axes tightbbox.
1 parent 0fe574e commit d530e47

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,22 +4143,24 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
41434143
self.apply_aspect()
41444144

41454145
if self.axison:
4146-
try:
4147-
bb_xaxis = self.xaxis.get_tightbbox(
4148-
renderer, for_layout_only=for_layout_only)
4149-
except TypeError:
4150-
# in case downstream library has redefined axis:
4151-
bb_xaxis = self.xaxis.get_tightbbox(renderer)
4152-
if bb_xaxis:
4153-
bb.append(bb_xaxis)
4154-
try:
4155-
bb_yaxis = self.yaxis.get_tightbbox(
4156-
renderer, for_layout_only=for_layout_only)
4157-
except TypeError:
4158-
# in case downstream library has redefined axis:
4159-
bb_yaxis = self.yaxis.get_tightbbox(renderer)
4160-
if bb_yaxis:
4161-
bb.append(bb_yaxis)
4146+
if self.xaxis.get_visible():
4147+
try:
4148+
bb_xaxis = self.xaxis.get_tightbbox(
4149+
renderer, for_layout_only=for_layout_only)
4150+
except TypeError:
4151+
# in case downstream library has redefined axis:
4152+
bb_xaxis = self.xaxis.get_tightbbox(renderer)
4153+
if bb_xaxis:
4154+
bb.append(bb_xaxis)
4155+
if self.yaxis.get_visible():
4156+
try:
4157+
bb_yaxis = self.yaxis.get_tightbbox(
4158+
renderer, for_layout_only=for_layout_only)
4159+
except TypeError:
4160+
# in case downstream library has redefined axis:
4161+
bb_yaxis = self.yaxis.get_tightbbox(renderer)
4162+
if bb_yaxis:
4163+
bb.append(bb_yaxis)
41624164
self._update_title_position(renderer)
41634165
axbbox = self.get_window_extent(renderer)
41644166
bb.append(axbbox)

0 commit comments

Comments
 (0)