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()

猜你喜欢

转载自www.cnblogs.com/shunguo/p/11398136.html