Skip to content

ENH: add width_ratios and height_ratios to subplots#23191

Merged
QuLogic merged 1 commit into
matplotlib:mainfrom
jklymak:enh-add-wr-hr
Jun 28, 2022
Merged

ENH: add width_ratios and height_ratios to subplots#23191
QuLogic merged 1 commit into
matplotlib:mainfrom
jklymak:enh-add-wr-hr

Conversation

@jklymak

@jklymak jklymak commented Jun 2, 2022

Copy link
Copy Markdown
Member

PR Summary

I'm guessing 99.9% of the use of gridspec_kws is to set the height or width ratios of axes. And it is pretty esoteric to ask people to know about gridspecs in order to access this. Here we add width_ratios and height_ratios to the subplots and subplot_mosaic calls.

Previously we would do

fig, axs = plt.subplots(1, 2, gridspec_kw={'width_ratios': [1, 2]})

This PR allows

fig, axs = plt.subplots(1, 2, width_ratios=[1, 2])

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@story645 story645 marked this pull request as ready for review June 2, 2022 17:38
@story645 story645 marked this pull request as draft June 2, 2022 17:39

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I support the idea.

Comment thread lib/matplotlib/figure.py Outdated
Comment thread lib/matplotlib/figure.py Outdated
@jklymak jklymak force-pushed the enh-add-wr-hr branch 2 times, most recently from 04b6ea9 to f1a8cce Compare June 7, 2022 10:50
Comment thread lib/matplotlib/pyplot.py Outdated
@jklymak jklymak marked this pull request as ready for review June 10, 2022 06:57
@jklymak jklymak added API: consistency Consistency of the matplotlib API, including naming, behavior, defaults, … New feature labels Jun 10, 2022
@jklymak

jklymak commented Jun 10, 2022

Copy link
Copy Markdown
Member Author

This is ready to go, and I'll argue its a pretty big quality of life enhancement for anyone making different-width/height plots.

Comment thread lib/matplotlib/figure.py Outdated
@jklymak jklymak force-pushed the enh-add-wr-hr branch 3 times, most recently from 2e60682 to 17978e7 Compare June 13, 2022 11:27
Comment thread lib/matplotlib/tests/test_subplots.py Outdated
Comment thread lib/matplotlib/tests/test_subplots.py Outdated
@QuLogic QuLogic linked an issue Jun 21, 2022 that may be closed by this pull request
@jklymak

jklymak commented Jun 23, 2022

Copy link
Copy Markdown
Member Author

@story645 got time for a quick second look?

@anntzer

anntzer commented Jun 23, 2022

Copy link
Copy Markdown
Contributor

Sorry for being late to the party, but see also #21942 (comment).
Edit: @jklymak made a strong reply at #21942 (comment).

Comment thread lib/matplotlib/figure.py Outdated
Comment thread lib/matplotlib/figure.py
Comment thread lib/matplotlib/tests/test_subplots.py
Comment thread lib/matplotlib/pyplot.py Outdated
Comment thread lib/matplotlib/pyplot.py
Comment thread lib/matplotlib/tests/test_subplots.py
@tacaswell tacaswell added this to the v3.6.0 milestone Jun 24, 2022
Comment thread lib/matplotlib/tests/test_subplots.py Outdated
Comment thread lib/matplotlib/pyplot.py Outdated

@tacaswell tacaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone can merge on CI green.

@jklymak

jklymak commented Jun 25, 2022

Copy link
Copy Markdown
Member Author

Squashed and rebased on master so font fix should be in there...

@QuLogic QuLogic merged commit b02334b into matplotlib:main Jun 28, 2022
@jklymak jklymak deleted the enh-add-wr-hr branch June 28, 2022 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API: consistency Consistency of the matplotlib API, including naming, behavior, defaults, … New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: add width/height_ratios to subplots and friends

6 participants