plot.py 文件源码

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

项目:mimclib 作者: StochasticNumerics 项目源码 文件源码
def plotTimeVsLvls(ax, runs, *args, **kwargs):
    """Plots Time vs TOL of @runs, as
    returned by MIMCDatabase.readRunData()
    ax is in instance of matplotlib.axes
    """
    ax.set_xlabel(r'$\ell$')
    ax.set_ylabel('Time (s)')
    ax.set_yscale('log')
    fnNorm = kwargs.pop("fnNorm")
    if "__calc_moments" in kwargs:
        _, _, Tl, M, _ = kwargs.pop("__calc_moments")
    else:
        _, _, Tl, M, _ = __calc_moments(runs,
                                        seed=kwargs.pop('seed', None),
                                        direction=kwargs.pop('direction', None), fnNorm=fnNorm)
    ax.xaxis.set_major_locator(MaxNLocator(integer=True))

    min_tl = np.nanpercentile(Tl, 5, axis=1)
    med = np.nanmean(Tl, axis=1)
    max_tl = np.nanpercentile(Tl, 95, axis=1)
    line = ax.errorbar(np.arange(0, len(Tl)),
                       med, yerr=[med-min_tl, max_tl-med],
                       *args, **kwargs)
    return line[0].get_xydata(), [line]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号