From the course: Python for Data Visualization (2019)

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Legends

Legends

- [Instructor] In this video, we're going to learn about plot legends. Plot legends assist in assigning meaning to your various plot elements. It is therefore important to make sure your legend doesn't cover up your plot elements. We'll first start by utilizing Matplotlib's MATLAB style syntax, to create a plot legend. As you see in this image, the legend is not in an ideal location. You can use the lock parameter to change where your legend is located. In this case, I'm telling it to go to the center-right. It's important to note, you could also move your legend outside the plotting area. What the code here is doing, is that moving legend slightly outside to the right of my plot, because all the way to the right would be 1.00, and I'm moving it all to way to the base of my plot. And as you see here, my legend is outside the plotting area. Keep in mind, you can also use Matplotlib's object-oriented syntax to create a legend. In the case of the code over here,…

Contents