python使用plot繪制未來15天氣溫折線圖
發(fā)布日期:2022-01-03 12:49 | 文章來源:源碼之家
本博文源于繪圖基礎(chǔ),主要講解如何用python的plot繪制氣溫的折線圖。先講解plot參數(shù)如何使用后給出一個氣溫折線圖樣例繪制
使用plot()繪制折線圖
plot(x,y,fmt,scalex=True,data=None,label=None,*args,**kwargs)
該函數(shù)常用參數(shù)的含義如下:
- x:表示x軸數(shù)據(jù)
- y表示y軸的數(shù)據(jù)
- fmt表示快速設(shè)置線條樣式的格式字符串
- label:表示應(yīng)用于圖例的標(biāo)簽文本
- plot()函數(shù)會返回一個包含Line2D類對象(代表線條)的列表
實例1:未來15天最高氣溫和最低氣溫
日期 | 最高氣溫 | 最低氣溫 |
---|---|---|
9月4日 | 32 | 19 |
9月5日 | 33 | 19 |
9月6日 | 34 | 20 |
9月7日 | 34 | 22 |
9月8日 | 33 | 22 |
9月9日 | 31 | 21 |
9月10日 | 30 | 22 |
9月11日 | 29 | 16 |
9月12日 | 30 | 18 |
9月13日 | 29 | 18 |
9月14日 | 26 | 17 |
9月15日 | 23 | 14 |
9月16日 | 21 | 15 |
9月17日 | 25 | 16 |
9月18日 | 31 | 16 |
實驗效果
實驗代碼
import matplotlib.pyplot as plt import numpy as np x = np.arange(4,19) y_max = np.array([32,33,34,34,33,31,30,29,30,29,26,23,23,25,31]) y_min = np.array([19,19,20,22,22,21,22,16,18,18,17,14,15,16,16]) # 繪制折線圖 plt.plot(x,y_max) plt.plot(x,y_min) plt.show()
到此這篇關(guān)于py使用plot繪制未來15天氣溫折線圖的文章就介紹到這了,更多相關(guān)py使用plot繪制未來15天氣溫折線圖內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
相關(guān)文章