matplotlib.style#

Styles are predefined sets ofrcParams that define the visual appearance ofa plot.

Customizing Matplotlib with style sheets and rcParams describes the mechanism and usageof styles.

TheStyle sheets reference gives an overview ofthe builtin styles.

matplotlib.style.context(style,after_reset=False)[source]#

Context manager for using style settings temporarily.

Parameters:
stylestr, dict, Path or list

A style specification. Valid options are:

str
  • One of the style names instyle.available (a builtin style ora style installed in the user library path).

  • A dotted name of the form "package.style_name"; in that case,"package" should be an importable Python package name, e.g. at/path/to/package/__init__.py; the loaded style file is/path/to/package/style_name.mplstyle. (Style files insubpackages are likewise supported.)

  • The path or URL to a style file, which gets loaded byrc_params_from_file.

dict

A mapping of key/value pairs formatplotlib.rcParams.

Path

The path to a style file, which gets loaded byrc_params_from_file.

list

A list of style specifiers (str, Path or dict), which are appliedfrom 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 tothe default style settings.

Note

This updates thercParams 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
  • One of the style names instyle.available (a builtin style ora style installed in the user library path).

  • A dotted name of the form "package.style_name"; in that case,"package" should be an importable Python package name, e.g. at/path/to/package/__init__.py; the loaded style file is/path/to/package/style_name.mplstyle. (Style files insubpackages are likewise supported.)

  • The path or URL to a style file, which gets loaded byrc_params_from_file.

dict

A mapping of key/value pairs formatplotlib.rcParams.

Path

The path to a style file, which gets loaded byrc_params_from_file.

list

A list of style specifiers (str, Path or dict), which are appliedfrom first to last in the list.

Notes

The followingrcParams are not related to style and will be ignored iffound in a style specification:

  • backend

  • backend_fallback

  • 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 torcParams defining that style.

This is meant to be read-only. Usereload_library to update.

matplotlib.style.available#

List of the names of the available styles.

This is meant to be read-only. Usereload_library to update.