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()
转载于:https://www.cnblogs.com/shunguo/p/11398136.html