如何打開matplotlib,Matplotlib - bar(條形圖)

 2023-10-06 阅读 26 评论 0

摘要:title: Matplotlib - bar(條形圖) categories: pythonMatplotlib tags:pythonMatplotlibComputer Drawing 主要內容:bar()生成條形圖 pyplot子模塊提供bar()函數來生成條形圖 from matplotlib import pyplot as pltx = [5, 8, 10] y = [12, 16, 6] x_2 =

title: Matplotlib - bar(條形圖)
categories:

  • python
  • Matplotlib
    tags:
  • python
  • Matplotlib
  • Computer Drawing

主要內容: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()

運行結果:

在這里插入圖片描述

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/123158.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息