以下是我正在处理的示例数据: -
Day1-G Day1-W Day2-G Day2-W Day3-G Day3-W
Deviation of 1 61 54 61 59 69 68
Deviation of 2 75 68 76 71 75 75
Deviation of 3 85 80 86 80 78 83
Deviation of 4 88 86 92 83 88 85
我要做的是在单独的图中绘制每行的条形图(偏差1到4),以显示每天G
和W
的效果。我想为G
和W
设置不同的颜色,以便轻松区分内容。以下示例代码生成了半期望的图: -
_winter = os.path.join(data_path, 'winter.xls')
xl = pd.ExcelFile(_winter)
df_win_max_temp = xl.parse("Min Temp")
row = df_win_min_temp.iloc[0]
dev_1 = row.plot(kind='bar', title="Winter Minimum Temperature ", stacked=True, figsize=(16, 9), legend=True, fontsize=14, grid=True,
color=['g', 'b'])
fig = dev_1.get_figure()
fig.tight_layout()
plt.subplots_adjust(bottom=.25)
plt.show()
上面的代码导致产生这个图:
我面临的问题是颜色值不会根据color=
语句而改变。如何为每个条形图绘制不同的颜色值。我想交替使用绿色和蓝色。