Matplotlib绘图工具的简单使用
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"C:\Windows\Fonts\simsun.ttc",size=10)
x = [i for i in range(11,31)]
a = [1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
b = [1,0,3,1,2,2,2,3,1,1,1,1,1,2,1,1,2,3,2,2]
'''
x轴 岁数
y轴 个数
# 个数
a = [1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
b = [1,0,3,1,2,2,2,3,1,1,1,1,1,2,1,1,2,3,2,2]
'''
plt.figure(figsize=(15,8),dpi=80)
plt.title('------属于我们的恋爱走势图------',fontproperties=font,fontsize='25')
plt.xticks(range(11,31),x,fontproperties=font,fontsize='11')
plt.yticks(range(len(a)),a,fontproperties=font,fontsize='11')
plt.xlabel('岁数',fontproperties=font,fontsize='13')
plt.ylabel('个数',fontproperties=font,fontsize='13')
plt.plot(x,a,marker='o',label='帅气的我',color='cyan',linestyle='-.')
plt.plot(x,b,marker='o',label='亲爱的同桌',color='blue',linestyle=':')
plt.legend(fontsize='16',prop=font)
plt.show()