-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Interactive save should respect 'savefig.facecolor' rcParam. #3437
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
Good point; I agree, the rcParams should be respected. I wonder, though, whether what is really needed is a little refactoring. It looks like the correct logic is in Figure.savefig, which also handles the savefig.transparent option. Why do we need both Figure.savefig and backend_bases.print_figure with such similar signatures and docstrings? It is hard to follow the trail of what gets called when a figure is saved; and it seems like saving a figure via the Toolbar should be able to take advantage of the same code that is invoked by explicitly calling Figure.savefig. |
Hi Eric, I'm not sure if your question was directed at me or other developers. The self.canvas.print_figure(*args, **kwargs) So the logic which implements the rcParams could be moved from |
Has anyone found a workaround for this in the meantime? No matter what I try, my interactive plots are saving with a white background which makes all of the labels completely unreadable. Do I have to waste time redesigning my color scheme or can someone point me in the right direction. This is what I have thusfar: lib_mpl.rcParams['savefig.dpi'] = graphDPI
lib_mpl.rcParams['savefig.facecolor'] = figbgColor
lib_mpl.rcParams['savefig.edgecolor'] = figbgColor
f,ax = lib_plt.subplots(facecolor=figbgColor) The dpi works just find but not the savefig.facecolor nor savefig.edgecolor Thanks, |
@braxtonj, I believe that the only two workarounds are: (1) save the figure programmatically via the |
@u55 Can you put in a PR with that change? |
Has any further work been done on this PR? I know there's a major update to mpl in the works (heard about it in various pycon/scipy talks). For GUI programs that are already using the built in mpl toolbar it would be nice to have the savefig button on the toolbar respect rcParams rather than having to manually add another GUI element to place a call programmatically to savefig() for the sole purpose of changing the facecolor of the saved image and thus essentially having a dead item in the built in toolbar ... |
ping @u55 |
closed by #6197 |
Hi matplotlib developers,
Currently, there is no way to set the figure facecolor when saving a figure interactively via the
NavigationToolbar2
graphical save button. All interactive backends, that I have tested, default to a white facecolor while ignoring the 'savefig.facecolor' rcParam. I propose to change this behavior such that every backend will respect the 'savefig.facecolor' rcParam.One possible option would be to edit the
save_figure
method of each backend-specific class which inherits frommatplotlib.backend_bases.NavigationToolbar2
in every backend. This seems tedious.Another option would be to edit the
print_figure
method inmatplotlib.backend_bases.FigureCanvasBase
, which every backend inherits from. This seems simpler.For instance, adding the following indicated lines to
matplotlib.backend_bases.FigureCanvasBase.print_figure
works for me.I don't use a custom 'edgecolor' often, but the interactive figure saving functionality should also be changed to use the 'savefig.edgecolor' rcParam.
I would be happy to create a pull request if the developers agree that this change is a good idea.
Thank you.
The text was updated successfully, but these errors were encountered: