- 积分
- 63464
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-7-23
- 最后登录
- 1970-1-1
|
发表于 2021-9-8 16:23:19
|
显示全部楼层
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.dates as mdate
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
##数据准备(文件读取 → 数据清洗)
df=pd.read_csv('data/58606_201903.csv')
df['Time']=pd.to_datetime(df['Time'])
t=np.array(df['Time']) #t = [datetime.strptime(d, '%Y/%m/%d %H:%M') for d in df['时间']]
tmp=np.array(df['Temperature'])
prs=np.array(df['Pressure'])
#rain=np.array(df['Rain'])
rain=df['Rain'].replace(9999,0.0)
td=np.array(df['Dew'])
##绘图部分
#画布“第一”!
#fig, ((ax1,ax2),(ax3,ax4))= plt.subplots(2,2,figsize=(9,5),dpi=100)
fig=plt.figure()
ax=fig.add_axes([0.05,0.05,0.8,0.8])
line1,=ax.plot(t, tmp, 'r-',linewidth=3.,label='气温')
plt.legend((line1,line2),('气温', '露点'), loc='best')
plt.title('南昌站实况时序图2')
ax.xaxis.set_major_formatter(mdate.DateFormatter('%d-%H')) |
|