Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc50db4

Browse files
committed
Rework plot types quiver
While quiver can be used on individual points, the most common use case is gridded data. We should use the common use case as the example. Another reason is that, `quiver()` is assigned to the arrays category in plot types.
1 parent 9b3129e commit fc50db4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

plot_types/arrays/quiver.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@
88
import matplotlib.pyplot as plt
99
import numpy as np
1010

11-
plt.style.use('_mpl-gallery')
11+
plt.style.use('_mpl-gallery-nogrid')
1212

1313
# make data
14-
phi = np.linspace(0, 2 * np.pi, 8)
15-
x, y = 4 + 1 * np.cos(phi), 4 + 1 * np.sin(phi)
16-
u, v = 1.5 * np.cos(phi), 1.5 * np.sin(phi)
14+
x = np.linspace(-4, 4, 6)
15+
y = np.linspace(-4, 4, 6)
16+
X, Y = np.meshgrid(x, y)
17+
U = X + Y
18+
V = Y - X
1719

1820
# plot
1921
fig, ax = plt.subplots()
2022

21-
ax.quiver(x, y, u, v, color="C0", angles='xy',
22-
scale_units='xy', scale=0.5, width=.05)
23+
ax.quiver(X, Y, U, V, color="C0", angles='xy',
24+
scale_units='xy', scale=5, width=.015)
2325

24-
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
25-
ylim=(0, 8), yticks=np.arange(1, 8))
26+
ax.set(xlim=(-5, 5), ylim=(-5, 5))
2627

2728
plt.show()

0 commit comments

Comments
 (0)