Skip to content

Commit d6a700d

Browse files
committed
Add even more mplot3d tests
1 parent ffc55ae commit d6a700d

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,9 @@ def test_axes3d_labelpad():
857857
ax.set_xlabel('X LABEL', labelpad=10)
858858
assert ax.xaxis.labelpad == 10
859859
ax.set_ylabel('Y LABEL')
860-
ax.set_zlabel('Z LABEL')
860+
ax.set_zlabel('Z LABEL', labelpad=20)
861+
assert ax.zaxis.labelpad == 20
862+
assert ax.get_zlabel() == 'Z LABEL'
861863
# or manually
862864
ax.yaxis.labelpad = 20
863865
ax.zaxis.labelpad = -40
@@ -1048,6 +1050,7 @@ def test_lines_dists_nowarning():
10481050

10491051
def test_autoscale():
10501052
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
1053+
assert ax.get_zscale() == 'linear'
10511054
ax.margins(x=0, y=.1, z=.2)
10521055
ax.plot([0, 1], [0, 1], [0, 1])
10531056
assert ax.get_w_lims() == (0, 1, -.1, 1.1, -.2, 1.2)
@@ -1492,6 +1495,9 @@ def test_equal_box_aspect():
14921495
ax.axis('off')
14931496
ax.set_box_aspect((1, 1, 1))
14941497

1498+
with pytest.raises(ValueError, match="Argument zoom ="):
1499+
ax.set_box_aspect((1, 1, 1), zoom=-1)
1500+
14951501

14961502
def test_colorbar_pos():
14971503
num_plots = 2
@@ -1509,6 +1515,55 @@ def test_colorbar_pos():
15091515
assert cbar.ax.get_position().extents[1] < 0.2
15101516

15111517

1518+
def test_inverted_zaxis():
1519+
fig = plt.figure()
1520+
ax = fig.add_subplot(projection='3d')
1521+
assert not ax.zaxis_inverted()
1522+
assert ax.get_zlim() == (0, 1)
1523+
assert ax.get_zbound() == (0, 1)
1524+
1525+
# Change bound
1526+
ax.set_zbound((0, 2))
1527+
assert not ax.zaxis_inverted()
1528+
assert ax.get_zlim() == (0, 2)
1529+
assert ax.get_zbound() == (0, 2)
1530+
1531+
# Change invert
1532+
ax.invert_zaxis()
1533+
assert ax.zaxis_inverted()
1534+
assert ax.get_zlim() == (2, 0)
1535+
assert ax.get_zbound() == (0, 2)
1536+
1537+
# Set upper bound
1538+
ax.set_zbound(upper=1)
1539+
assert ax.zaxis_inverted()
1540+
assert ax.get_zlim() == (1, 0)
1541+
assert ax.get_zbound() == (0, 1)
1542+
1543+
# Set lower bound
1544+
ax.set_zbound(lower=2)
1545+
assert ax.zaxis_inverted()
1546+
assert ax.get_zlim() == (2, 1)
1547+
assert ax.get_zbound() == (1, 2)
1548+
1549+
1550+
def test_set_zlim():
1551+
fig = plt.figure()
1552+
ax = fig.add_subplot(projection='3d')
1553+
assert ax.get_zlim() == (0, 1)
1554+
ax.set_zlim(zmax=2)
1555+
assert ax.get_zlim() == (0, 2)
1556+
ax.set_zlim(zmin=1)
1557+
assert ax.get_zlim() == (1, 2)
1558+
1559+
with pytest.raises(
1560+
TypeError, match="Cannot pass both 'bottom' and 'zmin'"):
1561+
ax.set_zlim(bottom=0, zmin=1)
1562+
with pytest.raises(
1563+
TypeError, match="Cannot pass both 'top' and 'zmax'"):
1564+
ax.set_zlim(top=0, zmax=1)
1565+
1566+
15121567
def test_shared_axes_retick():
15131568
fig = plt.figure()
15141569
ax1 = fig.add_subplot(211, projection="3d")

0 commit comments

Comments
 (0)