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.

import morethemes as mt

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")

Custom theme in matplotlib with the morethemes package: Financial Times

mt.set_theme("ft")

# This displays various matplotlib charts
mt.preview_theme()

Wall Street Journal

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

Custom theme in matplotlib with the morethemes package: Wall Street Journal

mt.set_theme("wsj")

# This displays various matplotlib charts
mt.preview_theme()

The Economist

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

Custom theme in matplotlib with the morethemes package: The Economist

mt.set_theme("economist")

# This displays various matplotlib charts
mt.preview_theme()

Urban

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

Custom theme in matplotlib with the morethemes package: Urban

mt.set_theme("urban")

# This displays various matplotlib charts
mt.preview_theme()

Minimal

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

Custom theme in matplotlib with the morethemes package: Minimal

mt.set_theme("minimal")

# This displays various matplotlib charts
mt.preview_theme()

Nature

Custom theme in matplotlib with the morethemes package: Nature

mt.set_theme("nature")

# This displays various matplotlib charts
mt.preview_theme()

Greenwave

Custom theme in matplotlib with the morethemes package: Greenwave

mt.set_theme("greenwave")

# This displays various matplotlib charts
mt.preview_theme()

Lumen

Custom theme in matplotlib with the morethemes package: Lumen

mt.set_theme("lumen")

# This displays various matplotlib charts
mt.preview_theme()

Ebonis

Custom theme in matplotlib with the morethemes package: Ebonis

mt.set_theme("ebonis")

# This displays various matplotlib charts
mt.preview_theme()

Lighter

Custom theme in matplotlib with the morethemes package: Lighter

mt.set_theme("lighter")

# This displays various matplotlib charts
mt.preview_theme()

VS Code dark

Custom theme in matplotlib with the morethemes package: VS Code dark

mt.set_theme("vscode-dark")

# This displays various matplotlib charts
mt.preview_theme()

Nord

Custom theme in matplotlib with the morethemes package: Nord

mt.set_theme("nord")

# This displays various matplotlib charts
mt.preview_theme()

Retro

Custom theme in matplotlib with the morethemes package: Retro

mt.set_theme("retro")

# This displays various matplotlib charts
mt.preview_theme()

Other themes

If you want to browse all themes, check out the dedicated documentation.

Going further