Matplotlib实例教程(一):柱状图(条形统计图)plt.bar()
生活随笔
收集整理的這篇文章主要介紹了
Matplotlib实例教程(一):柱状图(条形统计图)plt.bar()
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言
- 🔗 運行環境:python3
- 🚩 作者:K同學啊
- 📚 選自專欄:《Matplotlib教程》
- 🧿 優秀專欄:《Python入門100題》
- 🔥 推薦專欄:《小白入門深度學習》
- 🥇 精選專欄:《深度學習100例》
代碼實現
import matplotlib.pyplot as pltx1 = [1, 3, 4, 5, 6, 7, 9] y1 = [4, 7, 1, 6, 7, 5, 4]x2 = [2, 4, 6, 8, 10] y2 = [5, 5, 3, 4, 3]plt.figure(figsize=(8,6)) plt.bar(x1, y1, label="Red Bar", color='r') plt.bar(x2, y2, label="Green Bar", color='g')plt.xlabel("bar number", fontsize=12) plt.ylabel("bar height", fontsize=12)plt.title("Bar Chart Example",fontsize=14) plt.legend() plt.show()總結
以上是生活随笔為你收集整理的Matplotlib实例教程(一):柱状图(条形统计图)plt.bar()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第8天:我用AI算法造了一些“网红”
- 下一篇: Matplotlib实例教程(二)饼状图