Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MNT]: Interaction between savefig args transparent and facecolor/edgecolor make it impossible to spell out the signature of savefig #24413

Open
@anntzer

Description

@anntzer

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp