8000 Removed normalization of arrows in 3D quiver by DanHickstein · Pull Request #5458 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Next Next commit
Removed normalization of arrows in 3D quiver
I removed the normalization of the arrows in 3D quiver to match the
behavior of the 2D quiver plot. Also, I changed the default pivot point
to be ‘tail’ in order to match the 2D quiver plot. Also, clarified the
comment about normalizing the ‘uvw’ variable.
  • Loading branch information
DanHickstein committed Nov 10, 2015
commit a204ae0dc0c4bf4a5ec5e40c67512eaa13f2ef30
10 changes: 6 additions & 4 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2477,7 +2477,7 @@ def quiver(self, *args, **kwargs):

*X*, *Y*, *Z*:
The x, y and z coordinates of the arrow locations (default is
tip of arrow; see *pivot* kwarg)
tail of arrow; see *pivot* kwarg)

*U*, *V*, *W*:
The x, y and z components of the arrow vectors
Expand All @@ -2499,7 +2499,8 @@ def quiver(self, *args, **kwargs):

*pivot*: [ 'tail' | 'middle' | 'tip' ]
The part of the arrow that is at the grid point; the arrow
rotates about this point, hence the name *pivot*.
rotates about this point, hence the name *pivot*.
Default is 'tail'

Any additional keyword arguments are delegated to
:class:`~matplotlib.collections.LineCollection`
Expand All @@ -2508,6 +2509,7 @@ def quiver(self, *args, **kwargs):
def calc_arrow(uvw, angle=15):
"""
To calculate the arrow head. uvw should be a unit vector.
We normalize it here:
"""
# get unit direction vector perpendicular to (u,v,w)
norm = np.linalg.norm(uvw[:2])
Expand Down Expand Up @@ -2540,7 +2542,7 @@ def calc_arrow(uvw, angle=15):
# arrow length ratio to the shaft length
arrow_length_ratio = kwargs.pop('arrow_length_ratio', 0.3)
# pivot point
pivot = kwargs.pop('pivot', 'tip')
pivot = kwargs.pop('pivot', 'tail')

# handle args
argi = 6
Expand Down Expand Up @@ -2601,7 +2603,7 @@ def calc_arrow(uvw, angle=15):
# If any row of UVW is all zeros, don't make a quiver for it
mask = norm > 1e-10
XYZ = XYZ[mask]
UVW = UVW[mask] / norm[mask].reshape((-1, 1))
UVW = UVW[mask]

if len(XYZ) > 0:
# compute the shaft lines all at once with an outer product
Expand Down
0