April 2018
Beginner to intermediate
300 pages
7h 34m
English
To match data series on plots with their labels, such as by their line styles and marker styles, we add the following:
plt.legend()
The label of each data series can be specified within each plt.plot() command with the label parameter.
By default, Matplotlib chooses the best location to minimize overlap with data points and add transparency to the legend face color in case of overlapping. However, this does not always guarantee the location to be ideal in each case. To adjust the location, we can't pass loc settings , such as by using plt.legend(loc='upper left').
Possible loc settings are as follows:
Read now
Unlock full access