nb.py 文件源码

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

项目:hippylib 作者: hippylib 项目源码 文件源码
def animate(Vh, state, same_colorbar=True, colorbar=True,
            subplot_loc=None, mytitle=None, show_axis='off', logscale=False):

    fig = plt.figure()

    vmin = None
    vmax = None

    if same_colorbar:
        vmin = 1e30
        vmax = -1e30
        for s in state.data:
            smax = s.max()
            smin = s.min()
            if smax > vmax:
                vmax = smax
            if smin < vmin:
                vmin = smin

    def my_animate(i):
        time_stamp = "Time: {0:f} s"  
        obj = dl.Function(Vh, state.data[i])
        t = mytitle + time_stamp.format(state.times[i])
        plt.clf()
        return  plot(obj, colorbar=True, subplot_loc=None, mytitle=t, show_axis='off', vmin=vmin, vmax=vmax, logscale=False)

    return animation.FuncAnimation(fig, my_animate, np.arange(0, state.nsteps), blit=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号