|
|
|
|
# -*- coding: gbk -*-
|
|
|
|
|
import csv
|
|
|
|
|
from matplotlib import pyplot as plt, ticker
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
from matplotlib.ticker import MultipleLocator
|
|
|
|
|
|
|
|
|
|
filename = 'changsha<EFBFBD><EFBFBD><EFBFBD><EFBFBD>.csv'
|
|
|
|
|
|
|
|
|
|
with open(filename) as f:
|
|
|
|
|
reader = csv.reader(f)
|
|
|
|
|
header_row = next(reader)
|
|
|
|
|
|
|
|
|
|
#<23><>ȡÿ<C8A1><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dates: [datetime] = []
|
|
|
|
|
higts, lows = [], []
|
|
|
|
|
for row in reader:
|
|
|
|
|
try:
|
|
|
|
|
current_date = datetime.strptime(row[0], '%Y-%m-%d')
|
|
|
|
|
higt = int(row[1])
|
|
|
|
|
low = int(row[2])
|
|
|
|
|
except ValueError:
|
|
|
|
|
print(current_date, 'ȱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ')
|
|
|
|
|
else:
|
|
|
|
|
dates.append(current_date)
|
|
|
|
|
higts.append(higt)
|
|
|
|
|
lows.append(low)
|
|
|
|
|
|
|
|
|
|
#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>ͼ<EFBFBD><CDBC>,<2C><><EFBFBD>ô<EFBFBD><C3B4>ڴ<EFBFBD>С
|
|
|
|
|
fig = plt.figure(dpi=150, figsize=(12, 8))
|
|
|
|
|
#plot <20><><EFBFBD><EFBFBD>ͼ alpha=(0.1 - 0.9)<29><>ʾ<CABE><CDB8><EFBFBD>ȣ<EFBFBD>0Ϊȫ<C8AB><CDB8><EFBFBD><EFBFBD>1Ϊ<31><CEAA><EFBFBD><CDB8>
|
|
|
|
|
plt.plot(dates, higts, c='red', alpha=0.5)
|
|
|
|
|
plt.plot(dates, lows, c='blue', alpha=0.5)
|
|
|
|
|
#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
plt.fill_between(dates, lows, higts, facecolor='black', alpha=0.1)
|
|
|
|
|
#<23><><EFBFBD><EFBFBD>ͼ<EFBFBD>θ<EFBFBD>ʽ
|
|
|
|
|
plt.rcParams['font.sans-serif'] = ['SimHei']
|
|
|
|
|
plt.title('<EFBFBD><EFBFBD>ɳ2023ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ', fontsize=20, weight='bold', color='blue', fontstyle='italic', loc='center')
|
|
|
|
|
plt.xlabel('', fontsize=16)
|
|
|
|
|
#<23><><EFBFBD>ڱ<EFBFBD>ǩ<EFBFBD><C7A9>б
|
|
|
|
|
fig.autofmt_xdate()
|
|
|
|
|
plt.ylabel("<EFBFBD>¶<EFBFBD>", fontsize=16, loc='top')
|
|
|
|
|
plt.xlabel("<EFBFBD><EFBFBD>-<2D><>", fontsize=16, loc='right')
|
|
|
|
|
#<23><><EFBFBD>ÿ̶ȱ<CCB6><C8B1>ǵĴ<C7B5>С
|
|
|
|
|
plt.tick_params(axis='both', which='major',direction='in', pad=3,labelsize=16)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plt.savefig('<EFBFBD><EFBFBD>ɳ2023<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ.png')
|
|
|
|
|
plt.show()
|
|
|
|
|
|