import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-3, 3, 50)
y1 = 2 * x + 1
y2 = x * x
plt.figure(num=3, figsize=(8, 5))
# 设置范围
plt.xlim((-1, 2))
plt.ylim((-2, 3))
# 设置坐标轴含义
plt.xlabel('价格', fontproperties='SimHei')
plt.ylabel('利润', fontproperties='SimHei')
# 设置坐标轴刻度
new_xticks = np.linspace(-1, 2, 5)
plt.xticks(new_xticks)
plt.yticks([-2, -1.8, -1, 1.2, 3.], ['非常糟糕', '糟糕', r'$good\ \alpha$', r'$really\ good$', '超级好'],
fontproperties='SimHei')
l1, = plt.plot(x, y1)
l2, = plt.plot(x, y2, color='r', linewidth=1.0, linestyle='--')
# 设置图例
plt.legend(handles=[l1, l2], prop={'family': 'SimHei', 'size': 15}, loc='lower right', labels=['直线', '曲线'])
plt.show()