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

Skip to content

Commit cd4b311

Browse files
committed
pyplot.style.use() to accept pathlib.Path objects as arguments
1 parent 8ed7c78 commit cd4b311

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/matplotlib/style/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def use(style):
7272
7373
Parameters
7474
----------
75-
style : str, dict, or list
75+
style : str, dict, list or Path object
7676
A style specification. Valid options are:
7777
7878
+------+-------------------------------------------------------------+
@@ -85,12 +85,17 @@ def use(style):
8585
| list | A list of style specifiers (str or dict) applied from first |
8686
| | to last in the list. |
8787
+------+-------------------------------------------------------------+
88+
| Path | A Path object which is a path to a style file. |
89+
+------+-------------------------------------------------------------+
8890
"""
8991
style_alias = {'mpl20': 'default',
9092
'mpl15': 'classic'}
9193
if isinstance(style, str) or hasattr(style, 'keys'):
9294
# If name is a single str or dict, make it a single element list.
9395
styles = [style]
96+
elif isinstance(style, Path):
97+
# If the style is pathlib.Path object make a single element list of string
98+
styles = [str(style)]
9499
else:
95100
styles = style
96101

0 commit comments

Comments
 (0)