A description of 'Data' was assigned to the legend, and was placed in the upper right corner of the graph using the upper right value of the loc parameter. In the graph above, we described the plot using a legend. Plt.show() matplotlib graph with a legend You'll then learn how to change the font size of a Matplotlib legend using:Ī legend is a Matplotlib function used to describe elements that make up a graph.Ĭonsider the graph below: import matplotlib.pyplot as plt
In this article, you'll learn what a legend is in Matplotlib, and how to use some of its parameters to make your plots more relatable. You can modify different properties of a plot - color, size, label, title and so on - when working with Matplotlib.