Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

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 see our video player troubleshooting guide to resolve the issue.

Under the Hood: Matplotlib

00:00 A Look Under the Hood: Matplotlib. When you call .plot() on a DataFrame object, Matplotlib creates the plot under the hood. To verify this, try out two code snippets.

00:13 Firstly, create a plot with Matplotlib using two columns of your DataFrame. Firstly, the matplotlib.pyplot module is imported as plt.

00:26 Next, .plot() is called passing the DataFrame object’s "Rank" column as the first argument and "P75th" column as the second argument.

00:45 The result is a line graph that plots the 75th percentile on the y-axis against the rank on the x-axis. You can create exactly the same graph using the DataFrame object’s .plot() method.

01:03 .plot() is a wrapper for pyplot.plot(), and the result is a graph identical to the one you produced with Matplotlib directly. You can use pyplot.plot() and df.plot() to produce the same graph from columns of a DataFrame object. However, if you already have a DataFrame instance, then DataFrame.plot() offers a cleaner syntax than pyplot.plot().

01:29 If you’re already familiar with Matplotlib, then you may be interested in the kwargs parameter to .plot(). You can pass it a dictionary containing keyword arguments that will then be passed on to Matplotlib’s plotting backend. For more information on Matplotlib, check out Real Python’s Python Plotting With Matplotlib course.

01:51 Now that you know the DataFrame object’s .plot() method is a wrapper for Matplotlib’s pyplot.plot(), let’s dive into the different kinds of plots you can create and how to make them.

Become a Member to join the conversation.