#导入包
import xlrd
import os
import matplotlib.pyplot as plt
%matplotlib inline
#打开excel
date=xlrd.open_workbook('F:\\study\\python\\AREA.xlsx')
#筛选数据
table=date.sheets()[2]
x=(1,2,3,4,5,6)
y=table.row_values(0)
z=table.row_values(1)
a=table.row_values(2)
b=table.row_values(3)
#定义画布
plt.figure(dpi=300)
#绘图
plt.plot(x,y,color='b')
plt.plot(x,z,color='g')
plt.plot(x,a,color='r')
plt.plot(x,b,color='y')
plt.xticks([1,2,3,4,5,6],[r'Mid-Holocene',r'Current',r'RCP26',r'RCP40',r'RCP60',r'RCP85'])
o1=plt.plot(x,y,color='b',label='Gansu')
o2=plt.plot(x,z,color='g',label='Qinghai')
o3=plt.plot(x,a,color='r',label='Sichuan')
o4=plt.plot(x,b,color='y',label='Tibet')
plt.legend(bbox_to_anchor=(0.98,1.12),ncol=4)
plt.savefig("熊欢.png")
plt.show()
os.getcwd()#查看存储路径
python折线图
最新推荐文章于 2024-06-14 21:05:29 发布