1
正确用法
plt.xlabel('x')
如果首先错误使用
plt.xlabel = 'x'
那么再次使用正确用法也会报错:
TypeError: 'str' object is not callable
可以重启运行解决
2
plt.rcParams['font.sans-serif'] = ['Kaitt', 'SimHei']#显示中文
fig, ax = plt.subplots(1,2, figsize=[16,9], dpi=250)
ax[0].plot(....,label='举个例子')
ax[1].plot(....,label='举个栗子')
plt.legend()#显示图例
plt.show()
以上情况运行,只有ax[0][1]的图例显示,ax[0][0]不会显示
可以每个ax进行legend()
plt.rcParams['font.sans-serif'] = ['Kaitt', 'SimHei']#显示中文
fig, ax = plt.subplots(1,2, figsize=[16,9], dpi=250)
ax[0].plot(....,label='举个例子')
ax[0].legend()
ax[1].plot(....,label='举个栗子')
ax[1].legend()#显示图例
plt.show()