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
Set artist colors in one fell swoop #1147
Conversation
Currently only sets axes frame, tickmarks, ticklabels and gridlines (if they are on)
@@ -939,6 +939,11 @@ def set_color_cycle(self, clist): | |||
self._get_lines.set_color_cycle(clist) | |||
self._get_patches_for_fill.set_color_cycle(clist) | |||
|
|||
def set_artists_color(self, color): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obviously would need a docstring.
@@ -939,6 +939,23 @@ def set_color_cycle(self, clist): | |||
self._get_lines.set_color_cycle(clist) | |||
self._get_patches_for_fill.set_color_cycle(clist) | |||
|
|||
def set_artists_color(self, color): | |||
""" | |||
Set the colour of several artists to *color* in one move. The argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic: to be consistent with the majority of the rest of the documentation, US English spelling, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the spelling.
I am not entirely convinced of this implementation. Particularly, it is hard-coded which artists get colored, but the docs hint at it being possibly configurable. The choice of artists are (somewhat) arbitrary. However, the fact that this PR exists points to a need for smarter color management within mpl. |
Perhaps "logical" collection objects? These logical collections would hold weak references to a set of artists and would apply a particular property on all the artists in the collection. set only, no gets. Then, an axes object may have a few of these already set up for the user to use (and this could be used elsewhere). Furthermore, one could have a logical collection object that contains other logical collection objects. This generalizes fairly nicely, I think. |
Good idea. |
I like that idea. Presumably one would have to make a choice regarding what artists belong to a given collection? Or do you think that's something the user should set up? |
The idea would be that such an object merely serves as a convenience and Of course, a problem that may arise is if mpl becomes too married to such a |
In need of a MEP? There is a label for that if so (though you don't seem to be able to set labels to PRs...). |
I got a couple of MEPs to write up. I will probably do that after v1.2.0 |
Sounds good to me. @WeatherGod @pelson Thanks for the insightful comments. |
Currently only sets axes frame, tickmarks, ticklabels and gridlines (if they are on). This addresses issue #326.
I've thought a little bit about where this should live and considered putting it in
figure.py
, however I decided against this because the figure's colour (usingshow
) and the colour that's used when executingsavefig
are different. I wanted to give the user the option to choose this without touching it using theset_artists_color
method.Feedback welcome.