Skip to content

Add global config for FacetGrid to always follow matplotlib.rcParams['figure.figsize'] #11103

@dgkuester

Description

@dgkuester

Is your feature request related to a problem?

Most plots that I generate need to fit specific sizes depending on strict fixed formatting constraints for publication or presentation, particularly in IEEE publciations. To this end, I invested some effort in writing matplotlib style sheets that match the proportions needed for these venues. I was surprised when I noticed that passing col and/or row to the various .plot[.*](...) methods led to different figure sizes.

After some experimentation and reading through the docs (thanks for all the detail in those!), I eventually learned that this is because col and row lead to the FacetGrid layout mechanism. I understand and respect from the plotting docs that this behavior is deliberate in order to match seaborn. I also understand that I can force a specific figure size by explicitly passing a figsize argument.

In terms of API usage and discovery, however, I found it counterintuitive these keyword arguments would trigger changes in figure size, since they seem unrelated; I spent longer than I'd care to admit diagnosing why some of my plots were coming out different sizes.

Describe the solution you'd like

I had the idea that it could be nice if there were a global option (via xarray.set_option?) to adhere more strictly to matplotlib's RC parameters, rather than seaborn API conventions. That way, it would be easier for me to feel confident when autogenerating nice-looking figures that are subject to fixed size constraints.

I'm not sure if there are other style sheet parameters that would make sense to follow more strictly as well in a more general "publication mode"/"stylesheet mode", or if this parameter is an outlier.

Describe alternatives you've considered

For now, I've started explicitly passing in figsize=plt.rcParams['figure.figsize'] in many of my calls to .plot[.*]. That approach is working for now, but it feels like a workaround because it

  • Adds boilerplate
  • Requires careful attention to whether axis was also passed in, since they are mutually exclusive
  • Seems to defeat the basic purpose of defining the parameter in stylesheets

Additional context

No response

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