Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix #4855: Blacklist rcParams that aren't style #5440
Conversation
mdboom
added the
needs_review
label
Nov 8, 2015
mdboom
added this to the
next major release (2.0)
milestone
Nov 8, 2015
efiring
commented on an outdated diff
Nov 8, 2015
efiring
commented on an outdated diff
Nov 8, 2015
| @@ -34,11 +34,27 @@ | ||
| STYLE_FILE_PATTERN = re.compile('([\S]+).%s$' % STYLE_EXTENSION) | ||
| +# A list of rcParams that should not be applied from styles | ||
| +STYLE_BLACKLIST = set([ | ||
| + 'interactive', 'backend', 'backend.qt4', 'webagg.port', | ||
| + 'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback', | ||
| + 'toolbar', 'timezone', 'datapath', 'figure.max_open_warning', | ||
| + 'savefig.directory', 'tk.window_focus', 'hardcopy.docstring']) | ||
| + | ||
| + | ||
| +def _blacklist_style_params(d): |
efiring
Owner
|
efiring
commented on an outdated diff
Nov 8, 2015
| @@ -34,11 +34,27 @@ | ||
| STYLE_FILE_PATTERN = re.compile('([\S]+).%s$' % STYLE_EXTENSION) | ||
| +# A list of rcParams that should not be applied from styles | ||
| +STYLE_BLACKLIST = set([ | ||
| + 'interactive', 'backend', 'backend.qt4', 'webagg.port', | ||
| + 'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback', | ||
| + 'toolbar', 'timezone', 'datapath', 'figure.max_open_warning', | ||
| + 'savefig.directory', 'tk.window_focus', 'hardcopy.docstring']) | ||
| + | ||
| + | ||
| +def _blacklist_style_params(d): | ||
| + return dict((k, v) for (k, v) in d.items() if k not in STYLE_BLACKLIST) |
|
|
|
Should also remove all of the black-listed entries from |
|
@tacaswell: Good point about removing blacklisted entries from the classic style. Done. |
|
I think this one is good to go. |
WeatherGod
and 2 others
commented on an outdated diff
Nov 17, 2015
| @@ -71,18 +96,18 @@ def use(style): | ||
| for style in styles: | ||
| if not cbook.is_string_like(style): | ||
| - mpl.rcParams.update(style) | ||
| + _apply_style(style) | ||
| continue | ||
| elif style == 'default': | ||
| mpl.rcdefaults() |
WeatherGod
Member
|
WeatherGod
commented on the diff
Nov 17, 2015
| @@ -34,11 +35,35 @@ | ||
| STYLE_FILE_PATTERN = re.compile('([\S]+).%s$' % STYLE_EXTENSION) | ||
| +# A list of rcParams that should not be applied from styles | ||
| +STYLE_BLACKLIST = set([ | ||
| + 'interactive', 'backend', 'backend.qt4', 'webagg.port', | ||
| + 'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback', | ||
| + 'toolbar', 'timezone', 'datapath', 'figure.max_open_warning', | ||
| + 'savefig.directory', 'tk.window_focus', 'hardcopy.docstring']) |
mdboom
Owner
|
|
I think this raises a bit more general question of what is the line between styles and settings. There are tons of other settings such as the default keymappings, animation settings, and such that may or may not make sense as a "style". I am fine with what has been chosen so far, it is just a question of how much more do we want to blacklist. |
|
Also, do we know if people have been using style.use() as a convenient way to apply custom rcParams? If so, then this change could break that use-case (not that it would have been a good thing to do in the first place, though) |
No, but I know of at least three cases where style was used to turn interactive on and caused end users no end of trouble... ;) |
|
This is all fine, but we still don't have a definition that can help guide us in choosing what should and shouldn't be allowed in a style file. So, to get the conversation rolling, I'll propose a definition: "a non-style parameter is one whose change would have no effect after importing pyplot". This definition might not be good enough. Should the line be drawn at figure creation? axes creation? |
|
My definition is things that affect the appearance of the plot are style. Things that are related to the environment/platform in use and other technical considerations are not. |
|
@tacaswell: Any thoughts on the definition of "style parameters" here? |
|
I would say it has to have a visual effect, rather than a ui effect (interactive, key bindings, default file types) which i think lines up with what @mdboom said and is a super set of @WeatherGod. Things like dpi are on the edge and should probably be allowed. |
|
I've added a comment about what should be blacklisted. I hope that addresses the comments above, and otherwise this is good-to-merge. |
|
I think this is ready-to-merge, unless there are other comments. |
|
@mdboom, see @WeatherGod's first inline comment. |
efiring
added a commit
that referenced
this pull request
Dec 31, 2015
|
|
efiring |
8decc8c
|
efiring
merged commit 8decc8c
into matplotlib:master
Dec 31, 2015
efiring
removed the
needs_review
label
Dec 31, 2015
|
I have the impression that some might want tighter restrictions--a larger blacklist. Merging this does not preclude such changes, but it seems worthwhile to get the mechanism in place without further delay. |
jenshnielsen
referenced
this pull request
Jan 1, 2016
Closed
Using default style raises warnings about non style parameters #5777
|
Should this be backported to 2.0? |
|
yes. |
jenshnielsen
added a commit
to jenshnielsen/matplotlib
that referenced
this pull request
Jan 5, 2016
|
|
efiring + jenshnielsen |
4c319fc
|
mdboom commentedNov 8, 2015
Needs a what's new