源码:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.read_excel('jifen.xlsx')
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
x=df['年份']
print(x)
y=df['及格线']
print(y)
z=df['noting to do']
print(z)
w=df['work']
print(w)
q=df['work and shui']
print(q)
# 设置图框的大小
fig = plt.figure(figsize=(10,6))
# 绘图,做折线图
plt.plot(x,#x轴
y,#y轴
linestyle = '-', # 折线类型
linewidth = 2, # 折线宽度
color = 'steelblue', # 折线颜色
marker = 'o', # 点的形状
markersize = 6, # 点的大小
markeredgecolor='black', # 点的边框色
markerfacecolor='steelblue', # 点的填充色
label='及格线'#标签
)
plt.plot(x,#x轴
z,#y轴
linestyle = '-', # 折线类型
linewidth = 2, # 折线宽度
color = '#ff9999', # 折线颜色
marker = 'o', # 点的形状
markersize = 6, # 点的大小
markeredgecolor='black', # 点的边框色
markerfacecolor='#ff9999', # 点的填充色
label='nothing'#标签
)
plt.plot(x,#x轴
w,#y轴
linestyle = '-', # 折线类型
linewidth = 2, # 折线宽度
color = '#8c564b', # 折线颜色
marker = 'o', # 点的形状
markersize = 6, # 点的大小
markeredgecolor='black', # 点的边框色
markerfacecolor='#8c564b', # 点的填充色
label='work'#标签
)
plt.plot(x,#x轴
q,#y轴
linestyle = '-', # 折线类型
linewidth = 2, # 折线宽度
color = '#bcbd22', # 折线颜色
marker = 'o', # 点的形状
markersize = 6, # 点的大小
markeredgecolor='black', # 点的边框色
markerfacecolor='#bcbd22', # 点的填充色
label='work and shui'#标签
)
# 添加标题和坐标轴标签
plt.title('积分状况折线图')
plt.xlabel('年份')
plt.ylabel('分值')
plt.xticks(rotation = 60)#x轴标签倾斜60度
plt.legend(loc='best',frameon=False)#图例,显示label,去掉边框
plt.show()