Skip to content

Figure background is transparent when saving png from notebook backend. #8654

Closed

Description

@efiring

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
screenshot_gray_background

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

Activity

  1. added this to the milestone on May 23, 2017
  2. WeatherGod commented on May 23, 2017

    @WeatherGod
    Member
  3. anntzer commented on Aug 31, 2017

    @anntzer
    Contributor

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

  4. modified the milestones: , on Aug 31, 2017
  5. modified the milestones: , on Oct 9, 2017
  6. Atcold commented on Oct 18, 2017

    @Atcold

    This was hard to debug... There is already a figure.facecolor which should be controlling the figure's colour. What's this additional parameter?
    Now behaviour of inline and notebook are not consistent (meaning, I spent an hour trying to figure out why my scripts are not working interchangeably).

  7. anntzer commented on Oct 18, 2017

    @anntzer
    Contributor

    Feel free to put up a PR deprecating the rcparam (I would support doing so).

  8. github-actions commented on Apr 12, 2023

    @github-actions

    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!

  9. QuLogic commented on Apr 12, 2023

    @QuLogic
    Member

    This was deprecated in #10024 and removed in #12763.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions