Python Matplotlib Style

Amirali Sanatinia
Aug 23, 2017 · 2 min read

Matplotlib is a great and very capable plotting library for Python. Matplotlib 2.0 made a few changes to their default style that improved the look and feel the graphs. However, we can do more by defining our own settings. This is the setup that I usually use for my plots.

plt.style.use('seaborn-poster')
plt.style.use('fivethirtyeight')
plt.rcParams['axes.edgecolor'] = '#ffffff'
plt.rcParams['axes.facecolor'] = '#ffffff'
plt.rcParams['figure.facecolor'] = '#ffffff'
plt.rcParams['patch.edgecolor'] = '#ffffff'
plt.rcParams['patch.facecolor'] = '#ffffff'
plt.rcParams['savefig.edgecolor'] = '#ffffff'
plt.rcParams['savefig.facecolor'] = '#ffffff'
plt.rcParams['xtick.labelsize'] = 16
plt.rcParams['ytick.labelsize'] = 16

The following are three example from Matplotlib tutorial with our custom style.

To see list of available styles just use:

import matplotlib.pyplot as plt
print plt.style.available

To read more about other settings have a look at the documentation.

Written by

Security researcher, Computer Science PhD. http://www.ccs.neu.edu/home/amirali/ https://twitter.com/asanatinia

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade