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?

Asked By: PythonRunner

||

Answers:

You forgot to display the legend:

...
plt.legend(loc='best')
plt.show()

enter image description here

Answered By: mechanical_meat
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.