Adding a Legend to the Plot
In this lesson, we will learn how to add a legend to the plot.
We'll cover the following
What is a legend
?
A legend
provides a description for an element in the figure. A legend helps the user understand a figure when the figure contains many elements. For example, if there are two curves on a graph, then the legend can help the user distinguish between the curves.
There is more than one way to add a legend
to a figure. In this lesson, we will learn two methods. Both use the plot()
function. The difference, however, is in how the two methods set their labels.
Get hands-on with 1400+ tech skills courses.