Python 3.x 使用两个y轴时如何避免图例重叠?

Python 3.x 使用两个y轴时如何避免图例重叠?,python-3.x,matplotlib,Python 3.x,Matplotlib,我画了两张图,它们的图例重叠在另一张上面。 我怎样才能把“完美”和“不完美”这两个字都写下来而不重叠呢 plt.plot(wave_t, new_int_t, label='Perfect') #perfect plt.ylabel("Relative Intensity") plt.legend() ax2 = plt.twinx() ax2.plot(wave_t, int_t, c='C1', label='Imperfect') #imperfect ax2.set_ylabel("

我画了两张图,它们的图例重叠在另一张上面。 我怎样才能把“完美”和“不完美”这两个字都写下来而不重叠呢

plt.plot(wave_t, new_int_t, label='Perfect') #perfect
plt.ylabel("Relative Intensity")
plt.legend()

ax2 = plt.twinx()
ax2.plot(wave_t, int_t, c='C1', label='Imperfect')  #imperfect
ax2.set_ylabel("I(λ,T)")
ax2.legend()

plt.xlabel('Wavelength [nm]')
plt.title('Comparison of Lamp Spectrum')

您可以尝试
ax2.legend(loc='左上角')
@Tomerikoo有办法将图例组合在一起吗?有!这里:您可以尝试
ax2.legend(loc='左上角')
@Tomerikoo有办法将图例组合在一起吗?有!这里: