MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / context

Function context

lib/matplotlib/style/__init__.py:148–188  ·  view source on GitHub ↗

Context manager for using style settings temporarily. Parameters ---------- style : str, dict, Path or list A style specification. Valid options are: str - One of the style names in `.style.available` (a builtin style or a style installed

(style, after_reset=False)

Source from the content-addressed store, hash-verified

146
147@contextlib.contextmanager
148def context(style, after_reset=False):
149 """
150 Context manager for using style settings temporarily.
151
152 Parameters
153 ----------
154 style : str, dict, Path or list
155 A style specification. Valid options are:
156
157 str
158 - One of the style names in `.style.available` (a builtin style or
159 a style installed in the user library path).
160
161 - A dotted name of the form "package.style_name"; in that case,
162 "package" should be an importable Python package name, e.g. at
163 ``/path/to/package/__init__.py``; the loaded style file is
164 ``/path/to/package/style_name.mplstyle``. (Style files in
165 subpackages are likewise supported.)
166
167 - The path or URL to a style file, which gets loaded by
168 `.rc_params_from_file`.
169 dict
170 A mapping of key/value pairs for `matplotlib.rcParams`.
171
172 Path
173 The path to a style file, which gets loaded by
174 `.rc_params_from_file`.
175
176 list
177 A list of style specifiers (str, Path or dict), which are applied
178 from first to last in the list.
179
180 after_reset : bool
181 If True, apply style after resetting settings to their defaults;
182 otherwise, apply style on top of the current settings.
183 """
184 with mpl.rc_context():
185 if after_reset:
186 mpl.rcdefaults()
187 use(style)
188 yield
189
190
191def _update_user_library(library):

Callers

nothing calls this directly

Calls 1

useFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…