学习笔记-显示2014年最高/最低温度报表 附上代码
import csv
from datetime import datetime
from matplotlib import pyplot as plt
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:
current_date = datetime.strptime(row[0], "%Y-%m-%d")
dates.append(current_date)
high = int(row[1])
highs.append(high)
low = int(row[3])
lows.append(low)
fig = plt.figure(dpi=128, figsize=(10,8))
plt.plot(dates, highs, c="red")
plt.plot(dates, lows, c="blue")
plt.title("Daily high and low temperatures-2014", fontsize=18)
plt.xlabel("", fontsize=16)
fig.autofmt_xdate()
plt.ylabel("Temperarure(F)", fontsize=16)
plt.tick_params(axis="both", which = "major", labelsize=16)
plt.show()
存在x轴时间的bug,需后续解决
发现excel仅3步骤即可完成, 知道这是用于大数据
|