Skip to content

Commit f873277

Browse files
quiver: avoid divide by zero when normalizing
- (avoid unnecessary computation otherwise)
1 parent c3d60d3 commit f873277

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,10 +2984,9 @@ 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
29902987
if normalize:
2988+
norm = np.linalg.norm(UVW, axis=1)
2989+
norm[norm == 0] = 1
29912990
UVW = UVW / norm.reshape((-1, 1))
29922991

29932992
if len(XYZ) > 0:

0 commit comments

Comments
 (0)