Legends and annotations
Legends and annotations are effective tools to display information required to comprehend a plot in a glance. A typical plot will have the following additional information elements:
A legend describing the various data series in the plot. This is provided by invoking the matplotlib
legend()
function and supplying the labels for each data series.Annotations for important points in the plot. The matplotlib
annotate()
function can be used for this purpose. A matplotlib annotation consists of a label and an arrow. This function has many parameters describing the label and arrow style and position, so you may need to callhelp(annotate)
for a detailed description.Labels on the horizontal and vertical axes. These labels can be drawn by the
xlabel()
andylabel()
functions. We need to give these functions the text of the labels as a string and optional parameters such as the font size of the label.A descriptive title for the graph with the matplotlib
title()
function. Typically...