Style Sheets (Matplotlib)
Style sheets are named bundles of default settings that change a plot's whole look — colors, fonts, grid, background — in one line. plt.style.use('ggplot') restyles every subsequent plot at once.
Matplotlib
Rather than tweaking dozens of settings by hand, you apply a coherent theme: plt.style.use('seaborn-v0_8') or 'ggplot' or 'fivethirtyeight' instantly changes the color cycle, line widths, fonts, and background to match that look. plt.style.available lists every built-in style.
Styles compose: pass a list and later ones override earlier ones. To restyle only a block of code without affecting the rest of the program, use the context manager form, with plt.style.context('dark_background'): ..., which reverts automatically afterward.
Under the hood a style sheet just sets a batch of rcParams values, so anything a style changes you can also override manually. Style sheets are the quickest route to a consistent, professional appearance across all your figures.
Syntax
plt.style.use('ggplot') | with plt.style.context('dark_background'): ...Examples
Python — 'ggplot' is one of the built-in styles.
import matplotlib.pyplot as plt
print("ggplot" in plt.style.available)Output:
True