Python如何根據(jù)時(shí)間序列數(shù)據(jù)作圖
本例子程序展示了長(zhǎng)白山火山氣體地球化學(xué)2002年觀測(cè)數(shù)據(jù)中CO2和He兩種氣體元素深度的時(shí)間序列。程序中用到了常用的時(shí)間序列python數(shù)據(jù)處理方法,箭頭標(biāo)識(shí)方法,適合學(xué)習(xí)基本python作圖學(xué)習(xí)使用。程序中所用到的no09.csv數(shù)據(jù)樣式如下:

代碼如下
import pandas as pdimport matplotlib.pyplot as pltimport datetime df = pd.read_csv(’no09.csv’)t = df.iloc[0:200, 0]t = [datetime.datetime.strptime(i, ’%Y/%m/%d’) for i in t]co2 = [float(i) for i in df.iloc[0:200,1]]he = [float(i) for i in df.iloc[0:200,2]]plt.subplot(211)plt.plot(t, co2, ’o-’)plt.xlabel(’Date [Year/Month’)plt.ylabel(’CO2 / %’)plt.grid(ls = ’--’)plt.subplot(212)plt.plot(t, he, ’o-’)plt.xlabel(’Date [Year/Month]’)plt.ylabel(’He /ppm’)plt.annotate(’2002/07/07 165ppm’, xy = (datetime.datetime.strptime((’2002/07/07’), ’%Y/%m/%d’), 165), xytext = (datetime.datetime.strptime((’2002/08/01’), ’%Y/%m/%d’), 123), arrowprops = dict(facecolor = ’black’, shrink = 0.05, width = 2, headwidth = 6,headlength = 6))plt.grid(ls = ’--’)plt.show()
結(jié)果

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP新手必備的基礎(chǔ)知識(shí)2. asp文件用什么軟件編輯3. CentOS郵箱服務(wù)器搭建系列——SMTP服務(wù)器的構(gòu)建( Postfix )4. PHP基礎(chǔ)之生成器4——比較生成器和迭代器對(duì)象5. JAVA 實(shí)現(xiàn)延遲隊(duì)列的方法6. JS中6個(gè)對(duì)象數(shù)組去重的方法7. Vue axios獲取token臨時(shí)令牌封裝案例8. 通過(guò)IEAD+Maven快速搭建SSM項(xiàng)目的過(guò)程(Spring + Spring MVC + Mybatis)9. js實(shí)現(xiàn)計(jì)算器功能10. 利用CSS制作3D動(dòng)畫(huà)

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