Python自動(dòng)化操作實(shí)現(xiàn)圖例繪制
折線圖,柱狀圖,餅圖用于數(shù)據(jù)展示,更直觀的分析數(shù)據(jù)。實(shí)現(xiàn)繪制的效果圖如下



代碼 很簡(jiǎn)單,如下
import matplotlib.pyplot as pltplt.rcParams[’font.sans-serif’]=[’SimHei’] #用來(lái)正常顯示中文標(biāo)簽#數(shù)據(jù)源date=[’2018/7/21’,’2018/7/22’,’2018/7/23’,’2018/7/24’,’2018/7/25’,’2018/7/26’,’2018/7/27’,’2018/7/28’,’2018/7/29’,’2018/7/30’,’2018/7/31’]hebei= [69,32,35,32,87,88,98,65,66,89,74]shanxi=[13,45,67,89,32,55,66,32,53,66,89]#折線圖plt.plot(date,hebei,color=’red’,label=’河北’)plt.plot(date,shanxi,color=’blue’,label=’山西’)plt.xlabel(’日期’)plt.ylabel(’車次’)plt.title(’車次表’)plt.xticks(rotation=45) #閑轉(zhuǎn)45度plt.legend()plt.show()#柱狀圖plt.bar(date,hebei,color=’red’,label=’河北’)plt.bar(date,shanxi,color=’blue’,label=’山西’)plt.xlabel(’日期’)plt.ylabel(’車次’)plt.title(’車次表’)plt.xticks(rotation=45) #閑轉(zhuǎn)45度plt.legend()plt.show()#餅圖number=[777,444]province=[’河北’,’山西’]colors=[’red’,’blue’]plt.pie(x=number,labels=province,colors=colors)plt.legend()plt.show()
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 利用ajax+php實(shí)現(xiàn)商品價(jià)格計(jì)算2. HTML <!DOCTYPE> 標(biāo)簽3. JS圖片懶加載庫(kù)VueLazyLoad詳解4. Java實(shí)現(xiàn)的迷宮游戲5. Java利用TCP協(xié)議實(shí)現(xiàn)客戶端與服務(wù)器通信(附通信源碼)6. Java實(shí)現(xiàn)UDP通信過(guò)程實(shí)例分析【服務(wù)器端與客戶端】7. Vue基于iview table展示圖片實(shí)現(xiàn)點(diǎn)擊放大8. 使用AJAX(包含正則表達(dá)式)驗(yàn)證用戶登錄的步驟9. Java PreparedStatement用法詳解10. Python 解決火狐瀏覽器不彈出下載框直接下載的問(wèn)題

網(wǎng)公網(wǎng)安備