脑子 发表于 2020-3-21 00:17:00

【复习】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生成图例,并确定其位置

rsj0315 发表于 2020-4-2 21:31:58

真棒
页: [1]
查看完整版本: 【复习】matplotlib之图例设置