-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate savefig.facecolor, savefig.edgecolor, and savefig.transparent. #10023
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
Conversation
f2bb690
to
8d74de0
Compare
34b8bfc
to
f7e0424
Compare
When these are finally removed it's no longer possible to define a style with a on display figure facecolor that is different from the saved one right? So this will change the on-display of classic style to no longer have a gray facecolor? |
@jenshnielsen Are you advocating for the ability to have a style like that? I wonder if a |
Right now styles are only applied at figure/axes creation time, not at draw time, so savefig.style wouldn't help (what you'd really need is artist style sheets, but that's a much more complicated project). The "classic" style can be recovered by setting the patch background to transparent and the widget background to gray (see #9698 where I set it to white). This admittedly requires backend-dependent code, but I always assumed that the reason for the gray background in the classic style was exactly due to trying to match the widget color... In any case I agree it is less simple, and thus a tradeoff to consider. |
The gray background was more than likely because that’s what matlab did. But I don’t think that’s a good reason for us to carry this millstone around. |
actually, it is a little worse than that. Most style things are applied at
figure/axes/artist creation time... but not all. So, it is a terrible
mismash of lazy evaluation and immediate evaluation.
…On Tue, Dec 19, 2017 at 1:56 PM, Antony Lee ***@***.***> wrote:
Right now styles are only applied at figure/axes *creation* time, not at
draw time, so savefig.style wouldn't help (what you'd really need is artist
style sheets, but that's a much more complicated project).
The "classic" style can be recovered by setting the patch background to
transparent and the *widget* background to gray (see #9698
<#9698> where I set it to
white). This admittedly requires backend-dependent code, but I always
assumed that the reason for the gray background in the classic style was
exactly due to trying to match the widget color... In any case I agree it
is less simple, and thus a tradeoff to consider.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10023 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-EFqusLOHBgJJySpEv0h2WQyN4Upks5tCAb2gaJpZM4RER7d>
.
|
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.
This all seems reasonable to me. I didn't test all the deprecation statements work - hopefully not too negligent of me.
f7e0424
to
ff4e297
Compare
ff4e297
to
b6ebe16
Compare
fwiw the widget color can be set in a backend dependent fashion (except for gtk2, which I haven't tested, but should be easy too?) as follows:
(replace red by your favorite color, of course) |
They cause a number of complications for print_figure (which needs to temporarily switch the figure and axes face and edge colors) that are unnecessary (the user can directly set the color they wish (including transparent) on the figure patch instead; an rcParam is even available for that purpose).
b6ebe16
to
b20fd2f
Compare
punted to 3 as I think this needs a bit more thought about consequences. |
So if you have a white figure and want to save it transparently instead of
you would need to write
Or, inversely, if all figures are transparent by default and you wanted to have a white background, instead of
you would need
Is it 9 extra lines for saving a simple figure or am I missing something here? |
We could definitely come up with a better API to do these manipulations (and even make sure that they are included before removing the functionality from savefig), e.g.
etc. (yes, the style is currently not applied to existing figures). The point is that it doesn't really make sense to duplicate all the figure-and-axes manipulation API as keywords to savefig. Edit: or
(where properties_cm is like setp, but as a contextmanager) which works around the delayed style application problem. |
See also #7619 for someone being confused by the duplication. |
@anntzer is this still something you want to pursue? Not entirely sure a new context manager is any better than just passing kwargs to |
If you don't buy the above arguments, here is another one: In Jupyter/IPython using the inline backend we can easily display the figures with a different background via
if you then want to save it you will still want a white background mostly. So let's not break all the people's notebooks which use a different color than white as background. |
It's not clear how
is different from setting the rcParam (without checking I'd guess that it's redundant with what the rcParam offers; this kind of duplication seriously annoys me :/), so it'd go through the same deprecation. |
Sorry, if that wasn't clear. So there is no difference between
and
Both will create grey background figures in the notebook, and save figures with white background. But this PR intends to remove the |
Not supporting different "displaying" and "saving" background colors is indeed the intent of this PR, and like any other backcompat break, yes, some people will be annoyed by it. |
@anntzer I think this is a good idea in general. We have too many ways to achieve the same thing. But it seems like it needs more discussion, and probably more use cases carefully laid out. I'm going to close this old PR, and suggest we open an issue. If you feel this is something we should pursue, after a bit more documentation of the plan we could discuss on a call? Of course, feel free to re-open if you strongly feel this is the way to go, but I don't think we have enough consensus yet. |
I agree this is basically stuck needing more discussion for now. |
They cause a number of complications for print_figure (which needs to
temporarily switch the figure and axes face and edge colors) that are
unnecessary (the user can directly set the color they wish (including
transparent) on the figure patch instead; an rcParam is even available
for that purpose).
xref #9080 (fixed, but discussion still relevant), #9921.
PR Summary
PR Checklist