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

Skip to content

Commit 4de1eb4

Browse files
KentKent
Kent
authored and
Kent
committed
Add force_zorder test
1 parent 7596db7 commit 4de1eb4

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,3 +1425,86 @@ def test_subfigure_simple():
14251425
sf = fig.subfigures(1, 2)
14261426
ax = sf[0].add_subplot(1, 1, 1, projection='3d')
14271427
ax = sf[1].add_subplot(1, 1, 1, projection='3d', label='other')
1428+
1429+
1430+
@image_comparison(baseline_images=['force_zorder'], remove_text=True,
1431+
extensions=['png'])
1432+
def test_force_zorder():
1433+
fig = plt.figure()
1434+
ax1 = fig.add_subplot(221, projection='3d')
1435+
ax2 = fig.add_subplot(222, projection='3d')
1436+
ax2.force_zorder = True
1437+
1438+
# create a horizontal plane
1439+
corners = ((0, 0, 0), (0, 5, 0), (5, 5, 0), (5, 0, 0))
1440+
for ax in (ax1, ax2):
1441+
tri = art3d.Poly3DCollection([corners],
1442+
facecolors='white',
1443+
edgecolors='black',
1444+
zorder=1)
1445+
ax.add_collection3d(tri)
1446+
1447+
# plot a vector
1448+
ax.plot((2, 2), (2, 2), (0, 4), c='red', zorder=2)
1449+
1450+
# plot some points
1451+
ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10)
1452+
1453+
ax.set_xlim((0, 5.0))
1454+
ax.set_ylim((0, 5.0))
1455+
ax.set_zlim((0, 2.5))
1456+
1457+
ax3 = fig.add_subplot(223, projection='3d')
1458+
ax4 = fig.add_subplot(224, projection='3d')
1459+
ax4.force_zorder = True
1460+
1461+
dim = 10
1462+
X, Y = np.meshgrid((-dim, dim), (-dim, dim))
1463+
Z = np.zeros((2, 2))
1464+
1465+
angle = 0.5
1466+
X2, Y2 = np.meshgrid((-dim, dim), (0, dim))
1467+
Z2 = Y2 * angle
1468+
X3, Y3 = np.meshgrid((-dim, dim), (-dim, 0))
1469+
Z3 = Y3 * angle
1470+
1471+
r = 7
1472+
M = 1000
1473+
th = np.linspace(0, 2 * np.pi, M)
1474+
x, y, z = r * np.cos(th), r * np.sin(th), angle * r * np.sin(th)
1475+
for ax in (ax3, ax4):
1476+
ax.plot_surface(X2, Y3, Z3,
1477+
color='blue',
1478+
alpha=0.5,
1479+
linewidth=0,
1480+
zorder=-1)
1481+
ax.plot(x[y < 0], y[y < 0], z[y < 0],
1482+
lw=5,
1483+
linestyle='--',
1484+
color='green',
1485+
zorder=0)
1486+
1487+
ax.plot_surface(X, Y, Z,
1488+
color='red',
1489+
alpha=0.5,
1490+
linewidth=0,
1491+
zorder=1)
1492+
1493+
ax.plot(r * np.sin(th), r * np.cos(th), np.zeros(M),
1494+
lw=5,
1495+
linestyle='--',
1496+
color='black',
1497+
zorder=2)
1498+
1499+
ax.plot_surface(X2, Y2, Z2,
1500+
color='blue',
1501+
alpha=0.5,
1502+
linewidth=0,
1503+
zorder=3)
1504+
1505+
ax.plot(x[y > 0], y[y > 0], z[y > 0], lw=5,
1506+
linestyle='--',
1507+
color='green',
1508+
zorder=4)
1509+
ax.view_init(azim=-20, elev=20)
1510+
ax.axis('off')

0 commit comments

Comments
 (0)