Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c90bcfb

Browse filesBrowse files
committed
Fix #4855: Blacklist rcParams that aren't style
1 parent 781540e commit c90bcfb
Copy full SHA for c90bcfb

File tree

Expand file treeCollapse file tree

1 file changed

+19
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-3
lines changed

‎lib/matplotlib/style/core.py

Copy file name to clipboardExpand all lines: lib/matplotlib/style/core.py
+19-3Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,27 @@
3434
STYLE_FILE_PATTERN = re.compile('([\S]+).%s$' % STYLE_EXTENSION)
3535

3636

37+
# A list of rcParams that should not be applied from styles
38+
STYLE_BLACKLIST = set([
39+
'interactive', 'backend', 'backend.qt4', 'webagg.port',
40+
'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback',
41+
'toolbar', 'timezone', 'datapath', 'figure.max_open_warning',
42+
'savefig.directory', 'tk.window_focus', 'hardcopy.docstring'])
43+
44+
45+
def _blacklist_style_params(d):
46+
return dict((k, v) for (k, v) in d.items() if k not in STYLE_BLACKLIST)
47+
48+
3749
def is_style_file(filename):
3850
"""Return True if the filename looks like a style file."""
3951
return STYLE_FILE_PATTERN.match(filename) is not None
4052

4153

54+
def _apply_style(d):
55+
mpl.rcParams.use(blacklist_style_params(d))
56+
57+
4258
def use(style):
4359
"""Use matplotlib style settings from a style specification.
4460
@@ -71,18 +87,18 @@ def use(style):
7187

7288
for style in styles:
7389
if not cbook.is_string_like(style):
74-
mpl.rcParams.update(style)
90+
_apply_style(style)
7591
continue
7692
elif style == 'default':
7793
mpl.rcdefaults()
7894
continue
7995

8096
if style in library:
81-
mpl.rcParams.update(library[style])
97+
_apply_style(library[style])
8298
else:
8399
try:
84100
rc = rc_params_from_file(style, use_default_template=False)
85-
mpl.rcParams.update(rc)
101+
_apply_style(rc)
86102
except IOError:
87103
msg = ("'%s' not found in the style library and input is "
88104
"not a valid URL or path. See `style.available` for "

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.