Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Python Plotting With Matplotlib (Overview)

A picture is worth a thousand words, and with Python’s matplotlib library, it fortunately takes far less than a thousand words of code to create a production-quality graphic.

However, matplotlib is also a massive library, and getting a plot to look just right is often achieved through trial and error. Using one-liners to generate basic plots in matplotlib is relatively simple, but skillfully commanding the remaining 98% of the library can be daunting.

In this beginner-friendly course, you’ll learn about plotting in Python with matplotlib by looking at the theory and following along with practical examples. While learning by example can be tremendously insightful, it helps to have even just a surface-level understanding of the library’s inner workings and layout as well.

By the end of this course, you’ll:

  • Know the differences between PyLab and Pyplot
  • Grasp the key concepts in the design of matplotlib
  • Understand plt.subplots()
  • Visualize arrays with matplotlib
  • Plot by combining pandas and matplotlib

This course assumes you know a tiny bit of NumPy. You’ll mainly use the numpy.random module to generate “toy” data, drawing samples from different statistical distributions. If you don’t already have matplotlib installed, see the documentation for a walkthrough before proceeding.

00:00 Hi. This is Austin Cepalia with realpython.com. In this course, we’re going to learn how to utilize Matplotlib in order to produce high-quality graphics for visualizing data. Yeah, that’s right—we’re making all of the graphics you see onscreen.

00:18 Matplotlib is a plotting library used all around the world by scientists, engineers, mathematicians, and—well, just about anybody. It presents itself as pretty easy.

00:32 You can start making plots with just a few lines of code. But in order to make the most of the library, it’s important to understand some of what’s going on under the hood, or you’ll find yourself struggling when you try to plot something advanced.

00:47 It’s sort of like building a house. If you don’t have a sturdy foundation, you won’t have a house for very long. Matplotlib is a massive library, and so we can’t cover everything in this course. Instead, we’re just going to learn about the foundation of the library, and we’ll see how it’s used to build all different types of plots.

01:10 Installing Matplotlib can be done with pip. This will ensure you have all of the required dependencies, such as NumPy. While you’re at it, grab Pandas too.

01:21 That, we’ll be using later on. You can also grab a scientific computing package, such as Anaconda, which comes with Matplotlib and many other scientific computing libraries pre-installed. It will also allow you to create virtual environments—that’s what I’ll be using in this course.

01:41 This course assumes you have a basic understanding of both object-oriented programming as well as the NumPy library. If you’re not familiar with object-oriented programming, I’d highly suggest you watch my first Real Python video course Intro to Object-Oriented Programming in Python before continuing. As for NumPy, don’t sweat it—we’re going to learn everything we need to know about NumPy in the next video.

02:11 If you’re already familiar with NumPy, you can skip right to video three in the course.

02:18 One last thing: you might’ve heard in school before that math is not a spectator sport. Well, yeah—neither is Matplotlib. We’ll be dealing with lots of data, lots of different plot types, several Python libraries, and lots of individual adjustments for each element of our graphic. To make the most of this course, you’ll really want to copy the code you see me typing and modify it until you fully understand what’s going on.

02:49 Read the documentation, see what other parameters you can edit, and just have fun with it. This is not a course to be rushed through. Let’s get started.

Become a Member to join the conversation.