Multiple sub plots using matplotlib in python

I keep forgetting how to plot multiple graphs on a single plot. Then I came up with this wonderful blog and cheat sheet. Also check out Jake Vandeplas‘s chapter 4.08 from Python Data Science Handbook for a more comprehensive guide.

fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(8, 4))

 or

 fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(8, 4))

and call each axes from subplots to plot on them as ax[0].plot(), ax[1].hist() etc…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s