python-matplotlib绘制堆积的条形图

import matplotlib as mpl
import matplotlib.pyplot as plt
x=["a","b","c","d","e","f"]
y=[2,3,6,7,9,5,]
y1=[5,8,9,3,4,6,]
plt.xlim(0,20)
plt.barh(x,y,align="center",color="r",label="y")
plt.barh(x,y1,left=y,color="green",label="y1")
plt.legend()
plt.show()

posted @ 2019-08-23 09:36  朵朵奇fa  阅读(3271)  评论(0编辑  收藏  举报