8000 Tests, fix, and whats new from code review · matplotlib/matplotlib@6eb7b43 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6eb7b43

Browse files
Tests, fix, and whats new from code review
1 parent 672bd0f commit 6eb7b43

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

doc/users/next_whats_new/3d_axis_positions.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ You can now specify the positions of ticks and axis labels for 3D plots.
99
import matplotlib.pyplot as plt
1010

1111
positions = ['default', 'upper', 'lower', 'both', 'none']
12-
fig, axs = plt.subplots(1, 5, subplot_kw={'projection': '3d'})
12+
fig, axs = plt.subplots(1, len(positions), figsize=(20, 4),
13+
subplot_kw={'projection': '3d'})
1314
for ax, pos in zip(axs, positions):
1415
for axis in ax.xaxis, ax.yaxis, ax.zaxis:
15-
axis._label_position = pos
16-
axis._tick_position = pos
17-
ax.set(xlabel='x', ylabel='y', zlabel='z', title=pos)
16+
axis.set_label_position(pos)
17+
axis.set_ticks_position(pos)
18+
title = f'position="{pos}"'
19+
ax.set(xlabel='x', ylabel='y', zlabel='z', title=title)

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def _get_all_axis_line_edge_points(self, minmax, maxmin, axis_position=None):
345345
position='lower')
346346
edgep1_u, edgep2_u = self._get_axis_line_edge_points(minmax, maxmin,
347347
position='upper')
348-
if position in ('lower', 'both'):
348+
if axis_position in ('lower', 'both'):
349349
edgep1s.append(edgep1_l)
350350
edgep2s.append(edgep2_l)
351351
position.append('lower')

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ def test_invisible_ticks_axis():
5757
axis.line.set_visible(False)
5858

5959

60+
@mpl3d_image_comparison(['axis_positions.png'], style='mpl20')
61+
def test_axis_positions():
62+
positions = ['upper', 'lower', 'both', 'none']
63+
fig, axs = plt.subplots(2, 2, subplot_kw={'projection': '3d'})
64+
for ax, pos in zip(axs.flatten(), positions):
65+
for axis in ax.xaxis, ax.yaxis, ax.zaxis:
66+
axis.set_label_position(pos)
67+
axis.set_ticks_position(pos)
68+
title = f'{pos}'
69+
ax.set(xlabel='x', ylabel='y', zlabel='z', title=title)
70+
71+
6072
@mpl3d_image_comparison(['aspects.png'], remove_text=False, style='mpl20')
6173
def test_aspects():
6274
aspects = ('auto', 'equal', 'equalxy', 'equalyz', 'equalxz', 'equal')

0 commit comments

Comments
 (0)
0