Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Summary
In#24405 I tried to replace the current pyplot.savefig() wrapper manual implementation, which just has an unhelpful signature of*args, **kwargs
, by a standard autogenerated pyplot wrapper, which copies the signature of Figure.savefig, which should itself match the signature of FigureCanvasBase.print_figure -- except for the fact that savefig adds a "transparent" kwarg not present in print_figure (and for a discrepancy in the name of the first argument: fname vs filename).
Unfortunately, the "transparent" kwarg has some problematic semantics (when set to True -- nothing happens when it is set to False): it always makes axes transparent, but the figure is made transparent only if the "facecolor" and "edgecolor" kwargs areunset -- if "facecolor"/"edgecolor" areNone, then they are considered as set to the corresponding rcParams values (savefig.facecolor/savefig.edgecolor). This is actually documented behavior ("IfTrue, the Axes patches will all be transparent; the Figure patch will also be transparent unlessfacecolor and/oredgecolor are specified via kwargs.")
This means that the real signature of print_figure is notprint_figure(..., transparent=None [-> rcparam], facecolor=None [-> rcparam], edgecolor=None [-> rcparam], ...)
but that facecolor/edgecolor can indeed not appear explicitly in the signature, only implicitly via**kwargs
(or they have to instead default to some special placeholder like _UNSET). This is not a desirable state, e.g. due to the difficulty in providing introspection for the signature of savefig.
Proposed fix
Mildly break the API and instead maketransparent=True
override anything set by thefacecolor
andedgecolor
kwargs, which should be rarely(?) used anyways.
See also#9080 (comment).