Skip to content

Commit cc74fe0

Browse files
committed
Improve 3D quiver test
1 parent 651a874 commit cc74fe0

File tree

4 files changed

+18
-8
lines changed

4 files changed

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

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -758,15 +758,25 @@ def test_mixedsamplesraises():
758758

759759

760760
@mpl3d_image_comparison(
761-
['quiver3d.png', 'quiver3d_pivot_middle.png', 'quiver3d_pivot_tail.png'])
761+
['quiver3d.png'])
762762
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)
763+
fig = plt.figure()
764+
ax = fig.add_subplot(projection='3d')
765+
pivots = ['tip', 'middle', 'tail']
766+
colors = ['tab:blue', 'tab:orange', 'tab:green']
767+
for i, (pivot, color) in enumerate(zip(pivots, colors)):
768+
x, y, z = np.meshgrid([-0.5, 0.5], [-0.5, 0.5], [-0.5, 0.5])
769+
u = -x
770+
v = -y
771+
w = -z
772+
# Offset each set in z direction
773+
z += 2 * i
774+
ax.quiver(x, y, z, u, v, w, length=1, pivot=pivot, color=color)
775+
ax.scatter(x, y, z, color=color)
776+
777+
ax.set_xlim(-3, 3)
778+
ax.set_ylim(-3, 3)
779+
ax.set_zlim(-1, 5)
770780

771781

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

0 commit comments

Comments
 (0)