ENH: add get_gridspec convenience method to subplots - #11438
Conversation
ImportanceOfBeingErnest
left a comment
There was a problem hiding this comment.
This simplifies many cases where otherwise each axes would need to be created from a GridSpec individually.
There is indeed also no harm in introducing this as it only gives a shortcut to already present (but somehow hidden) methods.
Approved, but would like to see a proper documentation (possibly in a follow up PR), best within the gridspec tutorial.
|
OK, this now has documentation (example + tutorial edit). |
c84db54 to
4983637
Compare
| ----------------------------------------- | ||
|
|
||
| New method `.SubplotBase.get_gridspec` is added so that users can | ||
| easily get the gridspec that went into making as axes: |
4983637 to
101b34e
Compare
|
This needs a second review to merge, It’s a one-liner plus docs... |
timhoffm
left a comment
There was a problem hiding this comment.
You're having three times almost the same example, onces in "What's new", once within the gridspec tutorial once as a separate example. Is this duplication reasonable?
| ================================================== | ||
|
|
||
| Sometimes we want to combine two subplots in an axes layout created with | ||
| `.figure.subplots`. We can get the `.gridspec.Gridspec` from the axes |
There was a problem hiding this comment.
Links do not resolve. Possibly use ~.Figure.subplots and ~.gridspec.GridSpec
There was a problem hiding this comment.
Thanks!. I'll fix the links.
The whats new is kind of ephemeral.
My understanding is that there are two types of people in the matplotlib community (that actually read the docs): those that read the examples, and those that read the tutorials. Indeed a lot of the examples are historically just sections from some tutorials. I don't think the duplication is egregious, but happy to remove any/all if that is what folks want.
101b34e to
d2a1456
Compare
|
Recycling for CI |
|
Merging on a combination of @ImportanceOfBeingErnest 's review and reading it a second time forgetting I had already approved this PR and went to approve it again. |

PR Summary
As per #11434 its a bit of a pain to get the gridspec after calling
plt.subplots(). This change lets you do the following, where the only really change is that we don't have to do the more cumbersomegs = ax.get_suplotspec().get_gridspec(). Much more discoverable.To do: Add to gridspec tutorial which I'll d if this is in general OK. I don't see the harm in adding this.PR Checklist