Skip to content

Allow the user to specify a figure to reuse when creating a FacetGrid #2830

Open
@Erotemic

Description

@Erotemic

Currently FacetGrid and its consumers relplot and catplot will always create a new figure when you call them. In my workflow, I often like to create the figures or axes beforehand and then pass these as arguments to seaborn functions. This works with axes level plots line lineplot and scatterplot, where you can pass the ax parameter, and if you don't it uses plt.gca().

I would like to propose that FacetGrid should take a parameter fig=None, and if specified it uses it, otherwise it uses the existing code as such:

if fig is None:
        with mpl.rc_context({"figure.autolayout": False}):
            fig = plt.figure(figsize=figsize)

That would allow me to force specific plots to be associated with specific figure numbers, which helps me keep track of things as I work. I can make this PR if there is interest in this feature. I made a draft here: #2831 and I will work on the remaining bullet points if there is interest.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions