Skip to content

savefig.transparent has no effect when saving from UI #9080

Closed

Description

@anntzer

Bug report

Bug summary

The savefig.transparent rcparam does not affect figures saved from the GUI.

Code for reproduction

from pylab import *
rcParams["savefig.transparent"] = True
plot()
show()

then click on the save button to save a figure.

Actual outcome

The figure has opaque background.

Expected outcome

The figure should have transparent background, just as it has when calling savefig().

Matplotlib version

  • Operating System:
  • Matplotlib Version: 2.0.2 but apparently dates back to at least 1.5.0.
  • Python Version:
  • Jupyter Version (if applicable):
  • Other Libraries:

Activity

  1. WeatherGod commented on Aug 23, 2017

    @WeatherGod
    Member
  2. anntzer commented on Aug 23, 2017

    @anntzer
    ContributorAuthor

    I think this is different: I am specifically talking about a difference in behavior between interactive save and savefig.

  3. added this to the milestone on Aug 24, 2017
  4. tacaswell commented on Aug 24, 2017

    @tacaswell
    Member

    I suspect this has been here much longer and is related to the some what convoluted method that print_figure is finally called either going through the 'save' button or savefig. I have a vague memory of trying to trace through all of that a few years ago and giving up.

  5. u55 commented on Aug 25, 2017

    @u55
    Contributor

    There was a related pull request here: #6197 for savefig.facecolor and savefig.edgecolor. It should be simple to add savefig.transparent.

  6. anntzer commented on Aug 25, 2017

    @anntzer
    ContributorAuthor

    Looks like the following chunk from Figure.savefig

            if transparent:
                kwargs.setdefault('facecolor', 'none')
                kwargs.setdefault('edgecolor', 'none')
                original_axes_colors = []
                for ax in self.axes:
                    patch = ax.patch
                    original_axes_colors.append((patch.get_facecolor(),
                                                 patch.get_edgecolor()))
                    patch.set_facecolor('none')
                    patch.set_edgecolor('none')
    

    should be moved to print_figure (which savefig ultimately calls, so there's no need to keep it in both places).

  7. tacaswell commented on Aug 27, 2017

    @tacaswell
    Member

    Sounds reasonable.

    The restore code would also have to move.

  8. anntzer commented on Aug 29, 2017

    @anntzer
    ContributorAuthor

    I think the correct strategy is

    • quickfix: use savefig everywhere instead of print_figure,
    • later: move everything from savefig to print_figure, so that savefig is a completely empty wrapper for print_figure (we could also have moved everything from print_figure to savefig and have print_figure be a minimal dispatcher to the print_* methods, but that would cause a backcompatibility break as print_figure would lose some capabilities).
  9. anntzer commented on Sep 1, 2017

    @anntzer
    ContributorAuthor

    Closed by #9124.

  10. modified the milestones: , on Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions