Python Plotting With Matplotlib (Overview)
A picture is worth a thousand words, and with Python’smatplotlib 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 inmatplotlib is relatively simple, but skillfully commanding the remaining 98% of the library can be daunting.
In thisbeginner-friendly course, you’ll learn about plotting in Python withmatplotlib 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
pandasandmatplotlib
This course assumes you know a tiny bit of NumPy. You’ll mainly use thenumpy.random module to generate “toy” data, drawing samples from different statistical distributions. If you don’t already havematplotlib installed, see thedocumentation for a walkthrough before proceeding.
00:00Hi. This is Austin Cepalia with realpython.com. In this course,we’re going to learn how to utilize Matplotlib in order to producehigh-quality graphics for visualizing data. Yeah, that’s right—we’re making all of the graphics you see onscreen.
00:18Matplotlib 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:32You 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:47It’s sort of like building a house. If you don’t have a sturdy foundation,you won’t have a house for very long. Matplotlibis 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 howit’s used to build all different types of plots.
01:10Installing Matplotlib can be done withpip.This will ensure you have all of the required dependencies,such as NumPy. While you’re at it, grab Pandas too.
01:21That, 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 librariespre-installed. It will also allow you to create virtual environments—that’s what I’ll be using in this course.
01:41This course assumes you have a basic understanding of both object-orientedprogramming 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 courseIntro to Object-Oriented Programming in Pythonbefore 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:11If you’re already familiar with NumPy,you can skip right to video three in the course.
02:18One last thing: you might’ve heard in school before that math is not a spectatorsport. 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 ofour graphic. To make the most of this course,you’ll really want to copy the codeyou see me typing and modify it until you fully understand what’s going on.
02:49Read 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.
Course Contents

