Skip to content

Commit 345d4ca

Browse files
committed
Don't draw invisible 3D Axes
Also, add a test for cartesian Axes as well. Fixes matplotlib#23308
1 parent 97fc115 commit 345d4ca

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
# the tests with multiple threads.
4646

4747

48+
@check_figures_equal(extensions=["png"])
49+
def test_invisible_axes(fig_test, fig_ref):
50+
ax = fig_test.subplots()
51+
ax.set_visible(False)
52+
53+
4854
def test_get_labels():
4955
fig, ax = plt.subplots()
5056
ax.set_xlabel('x label')
@@ -7319,7 +7325,7 @@ def test_redraw_in_frame():
73197325
ax.redraw_in_frame()
73207326

73217327

7322-
def test_invisible_axes():
7328+
def test_invisible_axes_events():
73237329
# invisible axes should not respond to events...
73247330
fig, ax = plt.subplots()
73257331
assert fig.canvas.inaxes((200, 200)) is not None

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ def apply_aspect(self, position=None):
387387

388388
@martist.allow_rasterization
389389
def draw(self, renderer):
390+
if not self.get_visible():
391+
return
390392
self._unstale_viewLim()
391393

392394
# draw the background patch

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
image_comparison, remove_text=True, style='default')
2222

2323

24+
@check_figures_equal(extensions=["png"])
25+
def test_invisible_axes(fig_test, fig_ref):
26+
ax = fig_test.subplots(subplot_kw=dict(projection='3d'))
27+
ax.set_visible(False)
28+
29+
2430
def test_aspect_equal_error():
2531
fig = plt.figure()
2632
ax = fig.add_subplot(projection='3d')

0 commit comments

Comments
 (0)