FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[ENH]: Allow figaspect to use default width rather than default height · Issue #21539 · matplotlib/matplotlib · GitHub

Repository navigation

[ENH]: Allow figaspect to use default width rather than default height #21539

Open

Description

Problem

I was recently working on a long document involving several plots, and I wanted all of them to have a consistent width (thus keeping my title/label font sizes consistent throughout the document). The matploltib.figure.figaspect function does exactly this, except it uses the default figure height (rcParams['figure.figsize'][1]) as the dimension to keep consistent, rather than the width.

I ended up writing my own function to mimic figaspect except to use the default width rather than default height, but it seemed like this capability might be relatively unintrusively added to figaspect.

Proposed solution

My proposed solution is to add a single kwarg to figaspect that toggles whether the default dimension used is width or height. This would be something simple, named like fixed_dim or fixed_dimension, that is set to fixed_dim = 'height' by default (maintaining the current behavior), but allowing fixed_dim = 'width' to use the opposite dimension as the one to keep consistent.

(I'm happy to do the work seeing this change through if it gets support)

Additional context and prior art

Similar ideas were thrown around in #18244, though my impression that most of the consideration there was aimed towards allowing the figure size to scale.

Some of what I see as relevant takeaways from that issue thread (and my responses) seem to be:

  1. Constraining by width seems to be a relatively common (if not the predominant) mode when writing documents with similarly sized figures. Allowing figaspect to use the default width would be a natural way of managing the figure sizes in those circumstances.
  2. Adding kwargs promiscuously should be avoided, especially when those keywords enable mutually exclusive behaviors. Unlike some of the other discussion, a single fixed_dim kwarg would have a narrower scope and likely a simpler, more intuitive impact—no backwards compatibility issues, no "collateral damage" on other matplotlib features (e.g. does not affect the existing figure, figsize schematic; no outside docstrings to be updated), and no interfering behavior among mutually exclusive operations. It would simply swap the current "fix height, adjust width" behavior for a "fix width, adjust height" behavior.

Activity

  1. jklymak commented on Nov 7, 2021

    Member

    A you note above this has been asked for in the past, and not moved forward on as undesirable API clutter. If you want to set a fixed width, plt.figure(figsize=(w, w*a)) is pretty straight forward.

  2. mitchnegus commented on Nov 7, 2021

    ContributorAuthor

    Got it. I thought this was a slightly different approach from what had been proposed before, and might have offered a way to cleanly resolve your point there that widths are often a more natural fixed dimension but without adding too much clutter. Thanks for the feedback!

  3. github-actions commented on Nov 7, 2025

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  4. timhoffm commented on Nov 7, 2025

    Member

    IMHO trying to generalize figaspect is a lost cause. If we want a more general approach, a new figsize function would be more promising #28758 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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


      Back | FazBrowse Home | New Git URL