【复习】matplotlib之图例设置
# 设置图例import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,3,51)
y1 = 2*x+1
y2 = x**2
plt.figure(num=3,figsize=(7,5))
plt.plot(x,y1,label='line1')
plt.plot(x,y2,color='red',linewidth=1.0,label='line2')
plt.legend(loc="best")
plt.show()
label设置
legend生成图例,并确定其位置
真棒
页:
[1]