def add_direction_map(fig: Figure, mgrid, direction_map, freq=2, **kwargs):
"""Quiver plot of direction map
http://bokeh.pydata.org/en/latest/docs/gallery/quiver.html
Args:
fig:
mgrid:
direction_map:
**kwargs:
"""
X, Y = mgrid.values
U, V = direction_map
x0 = X[::freq, ::freq].flatten()
y0 = Y[::freq, ::freq].flatten()
x1 = x0 + 0.9 * freq * mgrid.step * U[::freq, ::freq].flatten()
y1 = y0 + 0.9 * freq * mgrid.step * V[::freq, ::freq].flatten()
fig.segment(x0, y0, x1, y1, **kwargs)
fig.triangle(x1, y1, size=4.0,
angle=np.arctan2(V[::freq, ::freq].flatten(),
U[::freq, ::freq].flatten()) - np.pi / 2)
评论列表
文章目录