How does one bring the legend to the foreground, erasing the curves that appear in the same space as the legend? I have read this, but this zorder
does not work in my case. I think the reason is that I don't have subfigures, just one figure.
The code is
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(index,a1, color='red', label=r'$E_i = \pm1.93$')
ax.plot(index,a2, color='blue', label=r'$E_j = \pm1.41$')
ax.plot(index,a3, color='green', label=r'$E_k = \pm0.51$')
plt.ylim([-0.05,1.05])
plt.xlabel(r'$x$', fontsize=18)
plt.ylabel(r'$y$', fontsize=18)
plt.xticks([0,10,20], ('0', '10', '20'), fontsize=18)
ax.legend(loc=1,bbox_to_anchor=(1,0.98), fontsize=13, frameon=False).set_zorder(2)