Plot Multiple Graphics in the Same Figure Using Python

Learn how to plot multiple graphics in the same matplotlib figure

Gustavo R Santos
Towards Data Science
4 min readJan 11, 2022

--

Photo by Pawel Czerwinski on Unsplash

If you work with Jupyter Notebooks, you know that the right side of it becomes really low populated when it comes to graphics. That happens because you usually create one graphic by cell and it does not take more than half of your screen.

However, sometimes it is necessary to plot two graphics side-by-side, not only for the sake of better space utilization, but mainly because we, as Data Scientists, frequently need to compare plots.

Let’s say you’re analyzing the distribution of trips of a Taxi company and you want to know what’s the difference in terms of distance between trips with the pickup happening in Manhattan versus Brooklyn.

Let’s load the dataset. I will use one of the sample datasets from seaborn package called Taxis. You can load it after importing seaborn.

import seaborn as sns# Load dataset
df = sns.load_dataset('taxis')
Taxis dataset from Seaborn. Image by the author.

Then let’s isolate the travels initiating in Manhattan and Brooklyn.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

--

--

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Written by Gustavo R Santos

Data Scientist | I solve business challenges through the power of data. | Visit my site: https://gustavorsantos.me

No responses yet

What are your thoughts?