-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Figure background is transparent when saving png from notebook backend. #8654
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
Comments
wasn't it a part of the 2.0 work to make the background transparent?
…On Mon, May 22, 2017 at 9:34 PM, Eric Firing ***@***.***> wrote:
Bug report
In Jupyter notebook with %matplotlib notebook:
*Code for reproduction*
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1,2])
fig.savefig('test.png')
I used a screenshot below instead of the file 'test.png' because the odd
background only shows up in preview, which evidently uses a light gray
background instead of the usual white.
*Actual outcome*
[image: screenshot_gray_background]
<https://cloud.githubusercontent.com/assets/85125/26334867/aeff9662-3f03-11e7-9030-b543c700522a.png>
*Expected outcome*
I expect the white figure background that results in the above example
when saving a pdf, or when using a different backend.
*Matplotlib version*
- Operating System: OS X 10.12.4
- Matplotlib Version: 2.0.2+7.ge6295a4a7
- Python Version: 3.5.2
- Jupyter Version (if applicable): 4.2.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8654>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-HfrTl5urWrqnHZLVVSm1Oi22Tetks5r8jengaJpZM4NjEyq>
.
|
Nah, this is controlled by the nbagg.transparent rcparam which has defaulted to true, well, probably ever since nbagg existed (https://github.com/matplotlib/matplotlib/pull/3560/files). TBH I don't see why this was even introduced (well, perhaps @pelson can comment on that :-)), although this may be related to defaulting to a white background in 2.0. Unless there's a compelling reason to keep it I would suggest deprecating this (figure.facecolor should be more than enough, especially now that you can set it using a RRGGBBAA string). |
This was hard to debug... There is already a |
Feel free to put up a PR deprecating the rcparam (I would support doing so). |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Bug report
In Jupyter notebook with
%matplotlib notebook
:Code for reproduction
I used a screenshot below instead of the file 'test.png' because the odd background only shows up in preview, which evidently uses a light gray background instead of the usual white.

Actual outcome
Expected outcome
I expect the white figure background that results in the above example when saving a pdf, or when using a different backend.
Matplotlib version
The text was updated successfully, but these errors were encountered: