plot.py 文件源码

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

项目:accpy 作者: kramerfelix 项目源码 文件源码
def plotbeamsigma(UC, diagnostics, s, sigx, sigy):
    fig = Figure()
    ax = fig.add_subplot(1, 1, 1)
    rel = abs(nanmean(sigy)/nanmean(sigx))
    if rel > 100 or rel < 1e-2:
        drawlattice(ax, UC, diagnostics, [sigx], 0)
        ax.plot(s, sigx, '-r', label=r'$\sigma_x$')
        ax.plot([], [], '-b', label=r'$\sigma_y$')
        ax.set_ylabel(r'Beam extent $\sigma_x$ / (m)')
        ax.set_xlabel(r'orbit position s / (m)')
        ax2 = ax.twinx()
        ax2.plot(s, sigy, '-b')
        ax2.tick_params(axis='y', colors='b')
        ax2.set_ylabel(r'Beam extent $\sigma_y$ / (m)', color='b')
    else:
        drawlattice(ax, UC, diagnostics, [sigx, sigy], 0)
        ax.plot(s, sigx, '-r', label=r'$\sigma_x$')
        ax.plot(s, sigy, '-b', label=r'$\sigma_y$')
        ax.set_xlabel(r'orbit position s / (m)')
        ax.set_ylabel(r'Beam extent $\sigma_u$ / (m)')
    ax.set_xlim([min(s), max(s)])
    leg = ax.legend(fancybox=True, loc=2)
    leg.get_frame().set_alpha(0.5)
    return fig
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号