import csv
from matplotlib import pyplot as plt
from datetime import datetime
filename="sitka_weather_2014.csv"
with open(filename) as f:
reader=csv.reader(f)
header_row=next(reader)
dates,highs,lows=[],[],[]
for row in reader:
highs.append(int(row[1]))
lows.append(int(row[3]))
dates.append(datetime.strptime(row[0],"%Y-%m-%d"))
fig=plt.figure(figsize=(15,8))
plt.plot(dates,highs,c='red',alpha=0.5)
plt.plot(dates,lows,c='blue',alpha=0.5)
plt.fill_between(dates,highs,lows,facecolor='blue',alpha=0.1)
plt.title("daily high temperatures,july 2014",fontsize=24)
plt.xlabel("",fontsize=16)
fig.autofmt_xdate()
plt.ylabel("f",fontsize=16)
plt.tick_params(axis='both',which='major',labelsize=16)
plt.show()
python处理下载的天气数据
最新推荐文章于 2024-03-21 17:21:05 发布