Titles and legends
We are about to introduce two other important plot features—titles and legends.
Adding a title
Just like in a book or a paper, the title of a graph describes what it is:
In [1]: import matplotlib.pyplot as plt
In [2]: plt.plot([1, 3, 2, 4])
Out[2]: [<matplotlib.lines.Line2D object at 0xf54f10>]
In [3]: plt.title('Simple plot')
Out[3]: <matplotlib.text.Text object at 0xf4b850>
In [4]: plt.show()
Matplotlib provides a simple function, plt.title(), to add a title to an image, as shown in the previous code. The following screenshot displays the output of the previous example:

Adding a legend
The last thing we need to see to complete a basic plot is a legend.
Legends are used to explain what each line means in the current figure. Let's take the multiline plot example again, and extend it with a legend:
In [1]: import matplotlib.pyplot as plt In [2]: import numpy as np In [3]: x = np.arange(1, 5) In [4]: plt.plot(x, x*1.5, label='Normal') Out[4]: [<matplotlib.lines...