最近有点闲暇时间,趁时学习一下Python,搭建好Python环境,环境搭建就不多说,网上很多教程,我使用的anaconda。然后开始了coding之路
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname='/Library/Fonts/Songti.ttc', size=15)
x1 = [2011, 2012, 2013, 2014, 2015]# Make x, y arrays for each graph
y1 = [100, 423, 934, 1600, 2542]
x2 = [2011, 2012, 2014, 2016, 2018]
y2 = [245, 466, 877, 1234, 1646]
#创建图并命名
plt.figure('chatView')
ax = plt.gca()
#设置x轴、y轴名称
ax.set_xlabel(u"年",fontproperties=font_set)
ax.set_ylabel(u"收入",fontproperties=font_set)
# 折线图
ax.plot(x1,y1,label=u"1111", color="r", linewidth=2, alpha=0.6)
ax.plot(x2,y2,label=u"2222