我想绘制一个直方图,我目前正在做:
plt.hist(y_pred_train_bdt[y_train_==0], color='r', alpha=0.6, range=high_low, bins=bins,
histtype='stepfilled', normed=True, label="b1")
plt.hist(y_pred_train_bdt[y_train_==2], color='y', alpha=0.5, range=high_low, bins=bins,
histtype='stepfilled', normed=True, label="b2")
plt.hist(y_pred_train_bdt[y_train_==3], color='orange', alpha=0.4, range=high_low, bins=bins,
histtype='stepfilled', normed=True, label="b3")
plt.hist(y_pred_train_bdt[y_train_==1], color='b', alpha=0.5, range=high_low, bins=bins,
histtype='stepfilled', normed=True, label="s1")
plt.hist(y_pred_train_bdt[y_train_==4], alpha=0.5, range=high_low, bins=bins,
histtype='stepfilled', normed=True, label="s2")
实际上,我只需要2个直方图,第一个是前3个直方图的总和“ b1”,“ b2”和“ b3”,第二个我要“ s1”和“ s2”。我希望第一个组件的3个组件和第二个组件的2个组件以不同的颜色可见。
如何绘制直方图,其中每个条形都有多种颜色,并且高度可以直观地显示每个成分的作用?
例如,如果在容器1中b1:b2:b3为1:2:3,则条形图的底部1/6应该为红色,然后2/6应该为黄色,最后3/6应该为橙色。