1

I was plotting two graphs and their legends are overlapping on top of another. How can I put the legend for both 'Perfect' and 'Imperfect" without being overlapped?

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')

enter image description here

JohanC
  • 71,591
  • 8
  • 33
  • 66
CapKoko
  • 49
  • 1
  • 5

0 Answers0