Skip to content

Commit 761414e

Browse files
authored
Merge pull request matplotlib#24995 from dstansby/3dquiver-test
Improve 3D quiver test
2 parents 3696e06 + 292c3ca commit 761414e

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed
Loading
Binary file not shown.
Binary file not shown.

Diff for: lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -757,16 +757,25 @@ def test_mixedsamplesraises():
757757
ax.plot_surface(X, Y, Z, cstride=50, rcount=10)
758758

759759

760-
@mpl3d_image_comparison(
761-
['quiver3d.png', 'quiver3d_pivot_middle.png', 'quiver3d_pivot_tail.png'])
760+
@mpl3d_image_comparison(['quiver3d.png'], style='mpl20')
762761
def test_quiver3d():
763-
x, y, z = np.ogrid[-1:0.8:10j, -1:0.8:10j, -1:0.6:3j]
764-
u = np.sin(np.pi * x) * np.cos(np.pi * y) * np.cos(np.pi * z)
765-
v = -np.cos(np.pi * x) * np.sin(np.pi * y) * np.cos(np.pi * z)
766-
w = (2/3)**0.5 * np.cos(np.pi * x) * np.cos(np.pi * y) * np.sin(np.pi * z)
767-
for pivot in ['tip', 'middle', 'tail']:
768-
ax = plt.figure().add_subplot(projection='3d')
769-
ax.quiver(x, y, z, u, v, w, length=0.1, pivot=pivot, normalize=True)
762+
fig = plt.figure()
763+
ax = fig.add_subplot(projection='3d')
764+
pivots = ['tip', 'middle', 'tail']
765+
colors = ['tab:blue', 'tab:orange', 'tab:green']
766+
for i, (pivot, color) in enumerate(zip(pivots, colors)):
767+
x, y, z = np.meshgrid([-0.5, 0.5], [-0.5, 0.5], [-0.5, 0.5])
768+
u = -x
769+
v = -y
770+
w = -z
771+
# Offset each set in z direction
772+
z += 2 * i
773+
ax.quiver(x, y, z, u, v, w, length=1, pivot=pivot, color=color)
774+
ax.scatter(x, y, z, color=color)
775+
776+
ax.set_xlim(-3, 3)
777+
ax.set_ylim(-3, 3)
778+
ax.set_zlim(-1, 5)
770779

771780

772781
@check_figures_equal(extensions=["png"])

0 commit comments

Comments
 (0)