2121
2222import matplotlib as mpl
2323from matplotlib import cbook
24- from matplotlib import rc_params_from_file , RcParams
24+ from matplotlib import rc_params_from_file
2525
2626
2727__all__ = ['use' , 'context' , 'available' , 'library' , 'reload_library' ]
@@ -44,19 +44,23 @@ def use(name):
4444
4545 Parameters
4646 ----------
47- name : str, list of str, or RcParams
48- Name of style or path/URL to a style file. For a list of available
49- style names, see `style.available`. If given a list, each style is
50- applied from first to last in the list. Instead of strings, each style
51- may also be specified directly as an instance of `RcParams`.
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.
5253 """
53- if cbook .is_string_like (name ) or isinstance (name , RcParams ):
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' ):
5456 name = [name ]
5557
5658 for style in name :
57- if isinstance ( style , RcParams ):
59+ if not cbook . is_string_like ( name ):
5860 mpl .rcParams .update (style )
59- elif style in library :
61+ continue
62+
63+ if style in library :
6064 mpl .rcParams .update (library [style ])
6165 else :
6266 try :
@@ -75,11 +79,12 @@ def context(name, after_reset=False):
7579
7680 Parameters
7781 ----------
78- name : str, list of str, or RcParams
79- Name of style or path/URL to a style file. For a list of available
80- style names, see `style.available`. If given a list, each style is
81- applied from first to last in the list. Instead of strings, each style
82- may also be specified directly as an instance of `RcParams`.
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.
8388 after_reset : bool
8489 If True, apply style after resetting settings to their defaults;
8590 otherwise, apply style on top of the current settings.
0 commit comments