16-1
#假设死亡谷的温度
import csv
from matplotlib import pyplot as plt
from datetime import datetime
filename='death_valley_2014.csv'
with open(filename) as f:
reader=csv.reader(f)
header_row=next(reader)
dates,highs,lows=[],[],[]
for row in reader:
current_date=datetime.strptime(row[0],"%Y-%m-%d")
dates.append(current_date)
highs.append(row[1])
lows.append(row[3])
print(highs)
print(lows)
#绘制图形
fig=plt.figure(dpi=128,figsize=(10,6))
plt.plot(dates,highs,c='red')
plt.plot(dates, lows, c='blue')
#设置图形格式
plt.title('Daily high temperatures温度',fontsize=24)
plt.xlabel('',fontsize=16)
plt.ylabel('Temperature F',fontsize=16)
plt.tick_params(axis='both',which='majior',labelsize=16)
fig.autofmt_xdate()
plt.show()