Custom theme in matplotlib with the morethemes package

Libraries

In order to change the theme of our matplotlib charts, we need to use the morethemes package, that you can install with pip install morethemes.

Default chart

morethemes provides a function that generates 4 charts with matplotlib. It's convenient to easily compare themes.

# This displays various matplotlib charts
fig = mt.preview_theme()

You might recognize all the default matplotlib style. Let's improve them with one line of code.

All themes

To apply a theme, you only have to run mt.set_theme("theme_name") before your matplotlib code. "theme_name" is the name of the theme and you can find all available theme here.

Financial Times

To use the Financial Times theme, run mt.set_theme("ft")

mt.set_theme("ft")

# This displays various matplotlib charts
mt.preview_theme()

/Users/josephbarbier/l/The-Python-Graph-Gallery/.venv/lib/python3.13/site-packages/morethemes/preview.py:12: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`. fig, axs = plt.subplots(ncols=2, nrows=2, figsize=(8, 6), dpi=200)

Wall Street Journal

To use the Wall Street Journal theme, run mt.set_theme("wsj")

mt.set_theme("wsj")

# This displays various matplotlib charts
mt.preview_theme()

The Economist

To use the Economist theme, run mt.set_theme("economist")

mt.set_theme("economist")

# This displays various matplotlib charts
mt.preview_theme()

Urban

To use the Urban theme, run mt.set_theme("urban")

mt.set_theme("urban")

# This displays various matplotlib charts
mt.preview_theme()

Minimal

To use the Minimal theme, run mt.set_theme("minimal")

mt.set_theme("minimal")

# This displays various matplotlib charts
mt.preview_theme()

Nature

mt.set_theme("nature")

# This displays various matplotlib charts
mt.preview_theme()

Greenwave

mt.set_theme("greenwave")

# This displays various matplotlib charts
mt.preview_theme()

Lumen

mt.set_theme("lumen")

# This displays various matplotlib charts
mt.preview_theme()

Ebonis

mt.set_theme("ebonis")

# This displays various matplotlib charts
mt.preview_theme()

Lighter

mt.set_theme("lighter")

# This displays various matplotlib charts
mt.preview_theme()

VS Code dark

mt.set_theme("vscode-dark")

# This displays various matplotlib charts
mt.preview_theme()

Nord

mt.set_theme("nord")

# This displays various matplotlib charts
mt.preview_theme()

Retro

mt.set_theme("retro")

# This displays various matplotlib charts
mt.preview_theme()