10000 Fix #4855: Blacklist rcParams that aren't style by mdboom · Pull Request #5440 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix #4855: Blacklist rcParams that aren't style #5440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 31, 2015

Conversation

mdboom
Copy link
Member
@mdboom mdboom commented Nov 8, 2015

Needs a what's new

@mdboom mdboom added this to the next major release (2.0) milestone Nov 8, 2015
def is_style_file(filename):
"""Return True if the filename looks like a style file."""
return STYLE_FILE_PATTERN.match(filename) is not None


def _apply_style(d):
mpl.rcParams.use(blacklist_style_params(d))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a leading underscore.

@tacaswell
Copy link
Member

Should also remove all of the black-listed entries from classic

@mdboom
Copy link
Member Author
mdboom commented Nov 12, 2015

@tacaswell: Good point about removing blacklisted entries from the classic style. Done.

@mdboom
Copy link
Member Author
mdboom commented Nov 17, 2015

I think this one is good to go.

@@ -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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bit of a disconnect here. rcdefaults() is more than just style stuff, but it doesn't make sense to blacklist entries there, either, does it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdboom, I think @WeatherGod has a good point here: 'default' style should modify only non-blacklisted things, shouldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. That makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@WeatherGod
Copy link
Member

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.

@WeatherGod
Copy link
Member

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)

@mdboom
Copy link
Member Author
mdboom commented Nov 17, 2015

Also, do we know if people have been using style.use() as a convenient way to apply custom rcParams?

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... ;)

@WeatherGod
Copy link
Member

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?

@mdboom
Copy link
Member Author
mdboom commented Nov 17, 2015

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.

@mdboom
Copy link
Member Author
mdboom commented Nov 20, 2015

@tacaswell: Any thoughts on the definition of "style parameters" here?

@tacaswell
Copy link
Member

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.

@mdboom
Copy link
Member Author
mdboom commented Dec 6, 2015

I've added a comment about what should be blacklisted. I hope that addresses the comments above, and otherwise this is good-to-merge.

@mdboom
Copy link
Member Author
mdboom commented Dec 29, 2015

I think this is ready-to-merge, unless there are other comments.

@efiring
Copy link
Member
efiring commented Dec 30, 2015

@mdboom, see @WeatherGod's first inline comment.

efiring added a commit that referenced this pull request Dec 31, 2015
Fix #4855: Blacklist rcParams that aren't style
@efiring efiring merged commit 8decc8c into matplotlib:master Dec 31, 2015
@efiring
Copy link
Member
efiring commented 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
Copy link
Member

Should this be backported to 2.0?

@mdboom
Copy link
Member Author
mdboom commented Jan 1, 2016

yes.

jenshnielsen pushed a commit to jenshnielsen/matplotlib that referenced this pull request Jan 5, 2016
@jenshnielsen jenshnielsen mentioned this pull request Jan 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0