Basic Text and Legend Functions
All of the functions we discuss in this topic, except for the legend, create and return a matplotlib.text.Text()
instance. We are mentioning it here so that you know that all of the properties discussed can be used for the other functions as well. All text functions are illustrated in Figure 3.13.
Labels
Matplotlib provides a few label functions that we can use for setting labels to the x- and y-axes. The plt.xlabel()
and plt.ylabel()
functions are used to set the label for the current axes. The set_xlabel()
and set_ylabel()
functions are used to set the label for specified axes.
Example:
ax.set_xlabel('X Label') ax.set_ylabel('Y Label')
You should (always) add labels to make a visualization more self-explanatory. The same is valid for titles, which will be discussed now.
Titles
A title describes a particular chart/graph. The titles are placed above the axes in the center, left edge, or right edge. There are two...