Note
Go to the end to download the full example code.
Customizing Matplotlib with style sheets and rcParams#
Tips for customizing the properties and default styles of Matplotlib.
There are three ways to customize Matplotlib:
Setting rcParams at runtime takes precedence over style sheets, style
sheets take precedence over matplotlibrc
files.
Runtime rc settings#
You can dynamically change the default rc (runtime configuration)
settings in a python script or interactively from the python shell. All
rc settings are stored in a dictionary-like variable called
matplotlib.rcParams
, which is global to the matplotlib package.
See matplotlib.rcParams
for a full list of configurable rcParams.
rcParams can be modified directly, for example:
from cycler import cycler
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2
mpl.rcParams['lines.linestyle'] = '--'
data = np.random.randn(50)
plt.plot(data)