我正在尝试绘制堆积的条形图,但没有成功。我正在使用的代码是:
A = [0.6746,.5469,.3765,0.1518,0.2]
B = [0.016,0.02,0.0279,0.2012,0.1517]
C = [0.3094,0.4331,0.5956,0.647,0.6483]
X = [1,2,3,4,5]
plt.bar(X,A,color ='b')
plt.bar(X,B,color ='r')
plt.bar(X,C,color ='g',bottom = A)
plt.show()
问题在于每列的总和为1。在条形图上,第4列和第5列的总和分别为0.7944和0.8422。第4列未显示蓝色部分。另外,绿色应该在底部。
任何提示将不胜感激。