我在数据框中有一大堆列,我正在这样绘制:
df.xs('Mean', level=1).cumsum().plot(cmap='winter').
这绘制了我所有列的均值随时间的累积和。 (0 级多索引是时间)但是,我想用不同的颜色突出显示图中的特定列,但我不确定如何去做。像这样:
df.xs('Mean', level=1).cumsum().plot(cmap='winter', color={'my_specific_column':'red'}).
这将沿着 'winter' cmap 光谱(蓝绿色到蓝色)绘制所有其他列,'my_specific_column' 除外,它将是红色。
有什么想法吗?
请您参考如下方法:
我认为简单的选择是绘制两次
to_draw = df.xs('Mean', level=1).cumsum()
fig, ax = plt.subplots()
to_draw.drop('my_specific_column', axis=1).plot(cmap='winter', ax=ax)
to_draw['my_specific_column'].plot(color='red', ax=ax, label='my_specific_column')
ax.legend()
