导航

python使用matplotlib输出柱状图

效果展示

 

 

代码展示:

from matplotlib import pyplot as plt
labels=['A','B','C']
values=[1,4,2]

plt.bar(labels[0],values[0] ,color = 'blue',hatch= "/")
plt.bar(labels[1],values[1] ,color = 'blue',hatch= "o")
plt.bar(labels[2],values[2] ,color = 'blue',hatch= "*")
plt.legend()
plt.savefig('image/tu3.png')
plt.show()

  

posted on 2021-10-14 15:36    阅读(65)  评论(0)    收藏  举报