Reverse the order of legend,"ax.legend(handles[::-1], labels[::-1], title='Line', loc='upper left')"