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
(style)
| 44 | "\n".join(map("- {}".format, sorted(_STYLE_BLACKLIST, key=str.lower))) |
| 45 | ) |
| 46 | def use(style): |
| 47 | """ |
| 48 | Use Matplotlib style settings from a style specification. |
| 49 | |
| 50 | The style name of 'default' is reserved for reverting back to |
| 51 | the default style settings. |
| 52 | |
| 53 | .. note:: |
| 54 | |
| 55 | This updates the `.rcParams` with the settings from the style. |
| 56 | `.rcParams` not defined in the style are kept. |
| 57 | |
| 58 | Parameters |
| 59 | ---------- |
| 60 | style : str, dict, Path or list |
| 61 | |
| 62 | A style specification. Valid options are: |
| 63 | |
| 64 | str |
| 65 | - One of the style names in `.style.available` (a builtin style or |
| 66 | a style installed in the user library path). |
| 67 | |
| 68 | - A dotted name of the form "package.style_name"; in that case, |
| 69 | "package" should be an importable Python package name, e.g. at |
| 70 | ``/path/to/package/__init__.py``; the loaded style file is |
| 71 | ``/path/to/package/style_name.mplstyle``. (Style files in |
| 72 | subpackages are likewise supported.) |
| 73 | |
| 74 | - The path or URL to a style file, which gets loaded by |
| 75 | `.rc_params_from_file`. |
| 76 | |
| 77 | dict |
| 78 | A mapping of key/value pairs for `matplotlib.rcParams`. |
| 79 | |
| 80 | Path |
| 81 | The path to a style file, which gets loaded by |
| 82 | `.rc_params_from_file`. |
| 83 | |
| 84 | list |
| 85 | A list of style specifiers (str, Path or dict), which are applied |
| 86 | from first to last in the list. |
| 87 | |
| 88 | Notes |
| 89 | ----- |
| 90 | The following `.rcParams` are not related to style and will be ignored if |
| 91 | found in a style specification: |
| 92 | |
| 93 | %s |
| 94 | """ |
| 95 | if isinstance(style, (str, Path)) or hasattr(style, 'keys'): |
| 96 | # If name is a single str, Path or dict, make it a single element list. |
| 97 | styles = [style] |
| 98 | else: |
| 99 | styles = style |
| 100 | |
| 101 | style_alias = {'mpl20': 'default', 'mpl15': 'classic'} |
| 102 | |
| 103 | for style in styles: |
no test coverage detected