Reputation: 201
I want to quickly plot a function varying one of its parameters and with a legend showing the value of this parameter:
def supergaussian1d(x, x0, Imax, FWHM, n):
return Imax * np.exp(-4 * np.log(2) * (np.sqrt((x + x0)**2) / FWHM) ** (2*n))
x = np.linspace(0, 15, num=100)
for m in range(2, 9):
plt.plot(x, supergaussian1d(x, x0=-7, Imax=10, FWHM=5, n=m), label='{}'.format(m))
plt.ylim((0, 12))
plt.show()
This is the output:
Why is the legend not displayed?
Also, does it make a difference whether or not plt.show()
is indented?
Upvotes: 0
Views: 241