I've copied some code from Stackoverflow to use a secondary Y-axis in order to improve the readability of my diagram. Sadly, only the legend to one y-axis is displayed.
The ones displayed are the ones that I include using plt.legend(). However, if I try to display both, using
ax1.legend()
ax2.legend()
Only the latter are shown. Here is the complete code
import matplotlib.pyplot as plt
x,y1,y2,y3,y4=[1,2],[0.5,1],[1,4],[1,2],[1,1.5]
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(x, y1, 'g-', label='y1')
ax1.plot(x, y2, 'r-', label='y2')
ax2.plot(x, y3, 'b-', label='y3')
ax2.plot(x, y4, 'y-', label='y4')
ax1.legend()
ax2.legend()
plt.show()