– Start
import numpy as np
import matplotlib.pyplot as plt
# 显示中文标签
# https://matplotlib.org/tutorials/introductory/customizing.html
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
x = np.arange(1, 100, 1)
y1 = x * 50
y2 = x ** 2
plt.plot(x, y1, label='直线')
plt.plot(x, y2, label='抛物线')
# 添加图例
# https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.legend
plt.legend(loc='upper left', frameon=True)
plt.show()
– 更多参见:Matplotlib 精萃
– 声 明:转载请注明出处
– Last Updated on 2021-01-13
– Written by ShangBo on 2021-01-13
– End