-
Notifications
You must be signed in to change notification settings - Fork 0
/
ndir.py
36 lines (26 loc) · 862 Bytes
/
ndir.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import plotly.figure_factory as ff
import plotly.graph_objects as go
import numpy as np
x,y = np.meshgrid(np.arange(-2, 2, .2),
np.arange(-2, 2, .25))
z = x*np.exp(-x**2 - y**2)
v, u = np.gradient(z, .2, .2)
# Create quiver figure# Create quiver figure
fig = ff.create_quiver(x, y, u, v,
scale=.25,
arrow_scale=.4,
name='quiver',
line_width=1)
# Add points to figure
fig.add_trace(go.Scatter(x=[-.7, .75], y=[0,0],
mode='markers',
marker_size=12,
name='points'))
fig.show()
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
q = ax.quiver(x, y, u, v)
ax.quiverkey(q, X=0.3, Y=1.1, U=10,
label='Quiver key, length = 10', labelpos='E')
plt.show()