EVI月变化时间序列绘图
1 导入相关模块
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib as mpl
2 加载数据
EVI = pd.read_excel(r'D:\Users\62692\Desktop\相关性分析.xlsx').loc[:,'EVI']
3 绘图
# 设置相关字体类型
mpl.rcParams["font.family"] = 'Times New Roman' #默认字体类型
mpl.rcParams["mathtext.fontset"] = 'cm' #数学文字字体
mpl.rcParams["font.size"] = 8
# 绘图
fig,ax = plt.subplots(1,1,figsize=(7,3),dpi=300,facecolor='white')
plt.rcParams['xtick.direction']='out' # x轴的刻度线向内显示
plt.rcParams['ytick.direction']='out' # y轴的刻度线向内显示
ax.plot(EVI.values, c= 'b',marker='.',label='EVI of Monthly Maximum')
ax.legend(frameon=False,loc='upper right',fontsize = 7)
# 设置x轴
ax.set_xticks(range(0,120,12))
ax.set_xticklabels(['2007-01','2008-01','2009-01','2010-01','2011-01','2012-01','2013-01','2014-01','2015-01','2016-01'],rotation=30,fontsize=8)
ax.set_xlabel('Month')
ax.set_ylabel('EVI')
plt.tight_layout()
plt.savefig(r'D:/Users/62692/Desktop/EVI_month.png',dpi=500)