On this page
matplotlib.style
Styles are predefined sets of rcParams
that define the visual appearance of a plot.
Customizing Matplotlib with style sheets and rcParams describes the mechanism and usage of styles.
The Style sheets reference gives an overview of the builtin styles.
- matplotlib.style.context(style, after_reset=False)
-
Context manager for using style settings temporarily.
- Parameters
-
- stylestr, dict, Path or list
-
A style specification. Valid options are:
str
The name of a style or a path/URL to a style file. For a list of available style names, see
style.available
.dict
Dictionary with valid key/value pairs for
matplotlib.rcParams
.Path
A path-like object which is a path to a style file.
list
A list of style specifiers (str, Path or dict) applied from first to last in the list.
- after_resetbool
-
If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings.
- matplotlib.style.reload_library()[source]
-
Reload the style library.
- matplotlib.style.use(style)[source]
-
Use Matplotlib style settings from a style specification.
The style name of 'default' is reserved for reverting back to the default style settings.
Note
This updates the
rcParams
with the settings from the style.rcParams
not defined in the style are kept.- Parameters
-
- stylestr, dict, Path or list
-
A style specification. Valid options are:
str
The name of a style or a path/URL to a style file. For a list of available style names, see
style.available
.dict
Dictionary with valid key/value pairs for
matplotlib.rcParams
.Path
A path-like object which is a path to a style file.
list
A list of style specifiers (str, Path or dict) applied from first to last in the list.
Notes
The following
rcParams
are not related to style and will be ignored if found in a style specification:- backend
- backend_fallback
- datapath
- date.epoch
- docstring.hardcopy
- figure.max_open_warning
- figure.raise_window
- interactive
- savefig.directory
- timezone
- tk.window_focus
- toolbar
- webagg.address
- webagg.open_in_browser
- webagg.port
- webagg.port_retries
- matplotlib.style.library
-
A dict mapping from style name to
RcParams
defining that style.This is meant to be read-only. Use
reload_library
to update.
- matplotlib.style.available
-
List of the names of the available styles.
This is meant to be read-only. Use
reload_library
to update.
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/style_api.html