pandas、plot笔记
程序员文章站
2022-05-02 22:14:05
...
pandas、plot笔记
def decorateAx(ax, xs, ys):
def x_fmt_func(x, pos=None):
idx = np.clip(int(x + 0.5), 0, len(xs) - 1)
return xs[idx]
idx_pxy = np.arange(len(xs))
ax.plot(idx_pxy, ys, color="green", linewidth=1, linestyle="-")
ax.plot(ax.get_xlim(), [0, 0], color="blue", linewidth=0.5, linestyle="--")
ax.xaxis.set_major_formatter(mtk.FuncFormatter(x_fmt_func))
ax.grid(True)
return
df1_t = df1[['Pnl','TraderA']]
df1_t_piv = df1_t.pivot(index=df1_t.index, columns = df1_t['TraderA'], values=df1_t['Pnl'])
df1_t_piv[-100:].cumsum().plot()
decorateAx(ax2, df1_t_piv.index[-100:], df1_t_piv[-100:].cumsum())
dfx= dfx.set_index('TraderId')
df1_traders = df1.loc[ [i_TraderA in ['Dlp', 'ZZCF'] for i_TraderA in df1['TraderA']], :]
df1_traders['Pnl'].cumsum().plot()
上一篇: 前端学习笔记_至今的学习总结
下一篇: html基础入门(二)