title: Matplotlib - bar(條形圖)
categories:
主要內容:bar()生成條形圖
pyplot子模塊提供bar()函數來生成條形圖
from matplotlib import pyplot as pltx = [5, 8, 10]
y = [12, 16, 6]
x_2 = [6, 9, 11]
y_2 = [6, 15, 7]plt.bar(x, y,align='center')
# 換顏色 green
plt.bar(x_2, y_2, color='g', align='center')
plt.title("Bar graph")
plt.ylabel("Y axis")
plt.xlabel("X axis")
plt.show()
運行結果:
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态