From the course: Python for Data Visualization

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Create legends

Create 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's 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 can also move your legend outside the plotting area. What the code here is doing is I'm moving the 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 the way at 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…

Contents