matplotlib label doesn't work
Question:
When I execute the following code, it doesn’t produce a plot with a label.
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 5)
plt.plot(x, x*1.5, label='Normal')
Numpy version is ‘1.6.2’
Matplotlib version is ‘1.3.x’
Any ideas as to why this is happening?
Answers:
You forgot to display the legend:
...
plt.legend(loc='best')
plt.show()
When I execute the following code, it doesn’t produce a plot with a label.
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 5)
plt.plot(x, x*1.5, label='Normal')
Numpy version is ‘1.6.2’
Matplotlib version is ‘1.3.x’
Any ideas as to why this is happening?
You forgot to display the legend:
...
plt.legend(loc='best')
plt.show()