8000 Merge pull request #15195 from anntzer/quiver3d-int · matplotlib/matplotlib@43f7f5a · GitHub
[go: up one dir, main page]

Skip to content

Commit 43f7f5a

Browse files
authored
Merge pull request #15195 from anntzer/quiver3d-int
Fix integers being passed as length to quiver3d.
2 parents 74e9dc7 + 3a324c0 commit 43f7f5a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,14 +2607,14 @@ def calc_arrow(uvw, angle=15):
26072607
self.add_collection(linec)
26082608
return linec
26092609

2610-
shaft_dt = np.array([0, length])
2610+
shaft_dt = np.array([0., length], dtype=float)
26112611
arrow_dt = shaft_dt * arrow_length_ratio
26122612

26132613
cbook._check_in_list(['tail', 'middle', 'tip'], pivot=pivot)
26142614
if pivot == 'tail':
26152615
shaft_dt -= length
26162616
elif pivot == 'middle':
2617-
shaft_dt -= length/2.
2617+
shaft_dt -= length / 2
26182618

26192619
XYZ = np.column_stack(input_args[:3])
26202620
UVW = np.column_stack(input_args[3:argi]).astype(float)

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,3 +970,19 @@ def get_formatters(ax, names):
970970
for fmt in get_formatters(row[4], names):
971971
fmt.set_useMathText(
972972
not mpl.rcParams["axes.formatter.use_mathtext"])
973+
974+
975+
@check_figures_equal(extensions=["png"])
976+
def test_quiver3D_smoke(fig_test, fig_ref):
977+
pivot = "middle"
978+
# Make the grid
979+
x, y, z = np.meshgrid(
980+
np.arange(-0.8, 1, 0.2),
981+
np.arange(-0.8, 1, 0.2),
982+
np.arange(-0.8, 1, 0.8)
983+
)
984+
u = v = w = np.ones_like(x)
985+
986+
for fig, length in zip((fig_ref, fig_test), (1, 1.0)):
987+
ax = fig.gca(projection="3d")
988+
ax.quiver(x, y, z, u, v, w, length=length, pivot=pivot)

0 commit comments

Comments
 (0)
0