Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17e8f9c

Browse files
committed
Update docstring for style.use() and style.context().
1 parent 998ac7e commit 17e8f9c

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

lib/matplotlib/style/core.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,26 @@ def is_style_file(filename):
3939
return STYLE_FILE_PATTERN.match(filename) is not None
4040

4141

42-
def use(name):
43-
"""Use matplotlib style settings from a known style sheet or from a file.
42+
def use(style):
43+
"""Use matplotlib style settings from a style specification.
4444
4545
Parameters
4646
----------
47-
name : str, dict, list of str and/or dict
48-
If `name` is a str, then it is the name of a style or a path/URL to a
49-
style file. For a list of available style names, see `style.available`.
50-
If `name` is a dict, then it contains valid rc key/value pairs. If
51-
`name` is a list of styles, then each style (str or dict) is applied
52-
from first to last in the list.
47+
style : str, dict, or list
48+
str: The name of a style or a path/URL to a style file. For a list of
49+
available style names, see `style.available`.
50+
dict: Dictionary with valid key/value pairs in `matplotlib.rcParams`.
51+
list: List of style specifiers (str or dict) applied from first to
52+
last in the list.
53+
5354
"""
54-
# If name is a single str or dict, make it a single element list.
55-
if cbook.is_string_like(name) or hasattr(name, 'keys'):
56-
name = [name]
55+
if cbook.is_string_like(style) or hasattr(style, 'keys'):
56+
# If name is a single str or dict, make it a single element list.
57+
styles = [style]
58+
else:
59+
styles = style
5760

58-
for style in name:
61+
for style in styles:
5962
if not cbook.is_string_like(style):
6063
mpl.rcParams.update(style)
6164
continue
@@ -74,25 +77,25 @@ def use(name):
7477

7578

7679
@contextlib.contextmanager
77-
def context(name, after_reset=False):
80+
def context(style, after_reset=False):
7881
"""Context manager for using style settings temporarily.
7982
8083
Parameters
8184
----------
82-
name : str, dict, list of str and/or dict
83-
If `name` is a str, then it is the name of a style or a path/URL to a
84-
style file. For a list of available style names, see `style.available`.
85-
If `name` is a dict, then it contains valid rc key/value pairs. If
86-
`name` is a list of styles, then each style (str or dict) is applied
87-
from first to last in the list.
85+
style : str, dict, or list
86+
str: The name of a style or a path/URL to a style file. For a list of
87+
available style names, see `style.available`.
88+
dict: Dictionary with valid key/value pairs in `matplotlib.rcParams`.
89+
list: List of style specifiers (str or dict) applied from first to
90+
last in the list.
8891
after_reset : bool
8992
If True, apply style after resetting settings to their defaults;
9093
otherwise, apply style on top of the current settings.
9194
"""
9295
initial_settings = mpl.rcParams.copy()
9396
if after_reset:
9497
mpl.rcdefaults()
95-
use(name)
98+
use(style)
9699
yield
97100
mpl.rcParams.update(initial_settings)
98101

0 commit comments

Comments
 (0)