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
评论列表
文章目录