Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit365c950

Browse files
authored
Merge pull request#27754 from AlecVercruysse/fixquiver
fix quiver3d incorrect arrow colors
2 parentsa7d0677 +0d5f822 commit365c950

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,15 +2984,10 @@ def calc_arrows(UVW):
29842984
UVW=np.column_stack(input_args[3:]).astype(float)
29852985

29862986
# Normalize rows of UVW
2987-
norm=np.linalg.norm(UVW,axis=1)
2988-
2989-
# If any row of UVW is all zeros, don't make a quiver for it
2990-
mask=norm>0
2991-
XYZ=XYZ[mask]
29922987
ifnormalize:
2993-
UVW=UVW[mask]/norm[mask].reshape((-1,1))
2994-
else:
2995-
UVW=UVW[mask]
2988+
norm=np.linalg.norm(UVW,axis=1)
2989+
norm[norm==0]=1
2990+
UVW=UVW/norm.reshape((-1,1))
29962991

29972992
iflen(XYZ)>0:
29982993
# compute the shaft lines all at once with an outer product
@@ -3006,7 +3001,7 @@ def calc_arrows(UVW):
30063001
# transpose to get a list of lines
30073002
heads=heads.swapaxes(0,1)
30083003

3009-
lines= [*shafts,*heads]
3004+
lines= [*shafts,*heads[::2],*heads[1::2]]
30103005
else:
30113006
lines= []
30123007

‎lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,8 @@ def test_mixedsamplesraises():
836836
ax.plot_surface(X,Y,Z,cstride=50,rcount=10)
837837

838838

839-
@mpl3d_image_comparison(['quiver3d.png'],style='mpl20')
839+
# remove tolerance when regenerating the test image
840+
@mpl3d_image_comparison(['quiver3d.png'],style='mpl20',tol=0.003)
840841
deftest_quiver3d():
841842
plt.rcParams['axes3d.automargin']=True# Remove when image is regenerated
842843
fig=plt.figure()
@@ -884,6 +885,19 @@ def test_quiver3d_masked():
884885
ax.quiver(x,y,z,u,v,w,length=0.1,pivot='tip',normalize=True)
885886

886887

888+
@mpl3d_image_comparison(['quiver3d_colorcoded.png'],style='mpl20')
889+
deftest_quiver3d_colorcoded():
890+
fig=plt.figure()
891+
ax=fig.add_subplot(projection='3d')
892+
893+
x=y=dx=dz=np.zeros(10)
894+
z=dy=np.arange(10.)
895+
896+
color=plt.cm.Reds(dy/dy.max())
897+
ax.quiver(x,y,z,dx,dy,dz,colors=color)
898+
ax.set_ylim(0,10)
899+
900+
887901
deftest_patch_modification():
888902
fig=plt.figure()
889903
ax=fig.add_subplot(projection="3d")
@@ -1555,7 +1569,8 @@ def test_minor_ticks():
15551569
ax.set_zticklabels(["half"],minor=True)
15561570

15571571

1558-
@mpl3d_image_comparison(['errorbar3d_errorevery.png'],style='mpl20')
1572+
# remove tolerance when regenerating the test image
1573+
@mpl3d_image_comparison(['errorbar3d_errorevery.png'],style='mpl20',tol=0.003)
15591574
deftest_errorbar3d_errorevery():
15601575
"""Tests errorevery functionality for 3D errorbars."""
15611576
t=np.arange(0,2*np.pi+.1,0.01)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp