A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.python-graph-gallery.com/custom-matplotlib-theme-with-morethemes below:

Website Navigation


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.

import pandas as pd
import matplotlib.pyplot as plt
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")

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

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4