Skip to content

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

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

Closed
anntzer opened this issue Aug 23, 2017 · 8 comments
Closed

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

anntzer opened this issue Aug 23, 2017 · 8 comments
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Aug 23, 2017

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:
@WeatherGod
Copy link
Member

WeatherGod commented Aug 23, 2017 via email

@anntzer
Copy link
Contributor Author

anntzer commented Aug 23, 2017

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

@tacaswell tacaswell added this to the 2.2 (next next feature release) milestone Aug 24, 2017
@tacaswell
Copy link
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.

@u55
Copy link
Contributor

u55 commented Aug 25, 2017

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

@anntzer
Copy link
Contributor Author

anntzer commented Aug 25, 2017

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

@tacaswell
Copy link
Member

Sounds reasonable.

The restore code would also have to move.

@anntzer
Copy link
Contributor Author

anntzer commented Aug 29, 2017

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

@anntzer
Copy link
Contributor Author

anntzer commented Sep 1, 2017

Closed by #9124.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants