Python自動化操作實現圖例繪制
折線圖,柱狀圖,餅圖用于數據展示,更直觀的分析數據。實現繪制的效果圖如下
代碼 很簡單,如下
import matplotlib.pyplot as pltplt.rcParams[’font.sans-serif’]=[’SimHei’] #用來正常顯示中文標簽#數據源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) #閑轉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) #閑轉45度plt.legend()plt.show()#餅圖number=[777,444]province=[’河北’,’山西’]colors=[’red’,’blue’]plt.pie(x=number,labels=province,colors=colors)plt.legend()plt.show()
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
相關文章:
1. Warning: require(): open_basedir restriction in effect,目錄配置open_basedir報錯問題分析2. ASP中常用的22個FSO文件操作函數整理3. php網絡安全中命令執行漏洞的產生及本質探究4. ASP的Global.asa文件技巧用法5. php測試程序運行速度和頁面執行速度的代碼6. html清除浮動的6種方法示例7. SharePoint Server 2019新特性介紹8. ASP中if語句、select 、while循環的使用方法9. React+umi+typeScript創建項目的過程10. Vue+elementUI下拉框自定義顏色選擇器方式