def plot_energy(curv, color=None, title='', figsize=(21,5),
nylabel=3, nxlabel=5, fontsize=24):
"""
Accepts the output of compute_curvature or combine_curvature and
returns a figure with appropriate styling.
"""
def _deltaE(col):
if col.name == 'n': return col
cat = np.linspace(col.values[0], 0, 51)
an = np.linspace(0, col.values[-1], 51)
return col - np.hstack([cat, an])
figargs = {'figsize': figsize}
fig = _gen_figure(nxplot=1, nyplot=3, nxlabel=nxlabel,
figargs=figargs, fontsize=fontsize)
ax, axnone, ax1 = fig.get_axes()
axnone.set_visible(False)
color = sns.color_palette('cubehelix', curv.shape[1] - 1) \
if color is None else color
plargs = {'x': 'n', 'color': color, 'title': title, 'legend': False}
curvy = curv.apply(_deltaE)
curv.plot(ax=ax, **plargs)
ax.set_ylim([curv.min().min(), curv.max().max()])
ax.set_ylabel('$\Delta$E (eV)', fontsize=fontsize)
ax.set_xlabel('$\Delta$N', fontsize=fontsize)
curvy.plot(ax=ax1, **plargs)
del curvy['n']
ax1.set_ylim([curvy.min().min(), curvy.max().max()])
ax1.set_ylabel('$\Delta \Delta$E (eV)', fontsize=fontsize)
ax.set_xlabel('$\Delta$N', fontsize=fontsize)
loc = [1.2, (9 - curv.shape[1]) / 25]
ax.legend(*ax.get_legend_handles_labels(), loc=loc)
return fig
评论列表
文章目录