visualizations.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:crowddynamics 作者: jaantollander 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号