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 - Python Tutorial
From the course: Python for Data Visualization
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Basics of Matplotlib3m 49s
-
(Locked)
Set marker type and colors1m 52s
-
(Locked)
MATLAB-style vs. object syntax2m 7s
-
(Locked)
Set titles, labels, and limits4m 21s
-
(Locked)
Add grids2m 26s
-
(Locked)
Create legends1m 25s
-
(Locked)
Save plots to files2m 28s
-
(Locked)
Create plots with Matplotlib wrappers5m
-
(Locked)
-
-