Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: add supxlabel and supylabel#17524

Merged
QuLogic merged 2 commits intomatplotlib:masterfrom
jklymak:enh-add-suplabels
Dec 3, 2020
Merged

ENH: add supxlabel and supylabel#17524
QuLogic merged 2 commits intomatplotlib:masterfrom
jklymak:enh-add-suplabels

Conversation

@jklymak
Copy link
Member

@jklymakjklymak commentedMay 28, 2020
edited
Loading

PR Summary

UPDATE: 10 Oct 2020, this still works as below.

There are a couple of fixes to padding insuptitle placement inconstrained_layout.

This PR addssupxlabel andsupylabel. Works with tight_layout and the new constrained_layout. Not so well with no layout manager ;-)

Closes#11147

importmatplotlib.pyplotaspltfortl,clinzip([True,False,False], [False,False,True]):fig=plt.figure(constrained_layout=cl,tight_layout=tl)gs=fig.add_gridspec(2,3)ax=dict()ax['A']=fig.add_subplot(gs[0,0:2])ax['B']=fig.add_subplot(gs[1,0:2])ax['C']=fig.add_subplot(gs[:,2])ax['C'].set_xlabel('Booger')ax['B'].set_xlabel('Booger')ax['A'].set_ylabel('Booger Y')fig.suptitle(f'TEST: tight_layout={tl} constrained_layout={cl}')fig.supxlabel('XLAgg')fig.supylabel('YLAgg')fig.savefig(f'/Users/jklymak/downloads/suplabels_tl{tl}_cl{cl}.png',dpi=75)plt.show()

suplabels_tlFalse_clFalse
suplabels_tlTrue_clFalse
suplabels_tlFalse_clTrue

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

coronakrisen, yudai-nkt, and orena1 reacted with thumbs up emoji
@jklymakjklymakforce-pushed theenh-add-suplabels branch 2 times, most recently fromd53bc29 tod1a0cc4CompareMay 28, 2020 01:50
@jklymakjklymak added status: waiting for other PR topic: geometry managerLayoutEngine, Constrained layout, Tight layout labelsMay 28, 2020
@jklymakjklymak marked this pull request as draftMay 28, 2020 02:02
@timhoffm
Copy link
Member

Have you considered that people might want suplabels on parts of a grid? e.g. columns 1 and 2 share an xlabel while column 0 has it's own label.

I'm not claiming that you should implement it now or even that it's necessary, but the desire may come up. If we consider this a reasonable extension, we should at least think about if an extension of the proposed API in that direction is possible and staight forward.

@jklymak
Copy link
MemberAuthor

Right now the API is the same assuptitle, and that has the same potential to only apply to some axes and not others.

There are two somewhat orthogonal issues here.

  1. suplabels don’t align with axes, they align w/ the figure. It’s a reasonable extension to align them with the spines of the child axes, but I’ve not implemented this here. It’s non trivial to do so in a way that works with all the layout managers...
  2. How do you only label a subset of axes? I’d argue this is best served with the subpanels/subfigure concept. Then the subpanel gets the suplabels. I think we should make subpanels subclasses of figures (in some way) so they will get this change for free.
timhoffm reacted with thumbs up emoji

@jklymak
Copy link
MemberAuthor

jklymak commentedMay 29, 2020
edited
Loading

i.e. this figure just has suptitles for each subpanel, but was made w two subpanels, and could just as easily have supx and supylabels (from#17437)

suptitles

timhoffm, coronakrisen, and sks-2020 reacted with thumbs up emoji

@jklymakjklymak mentioned this pull requestJun 15, 2020
6 tasks
@sks-2020
Copy link

Could the functions to add supxlabels and supylabels please be added to future releases of gridspec? Also have multicolumn row titles in the gridspec layout, as in the below figure?

image

@jklymak
Copy link
MemberAuthor

@sks-2020 What do you anticipate wanting to do with gridspec that the sub-panel functionality won't give you?

sks-2020 reacted with thumbs up emoji

@sks-2020
Copy link

@jklymak I think the subpanel function will solve what I am hoping to do. My issue is the same as outlined here:
https://stackoverflow.com/questions/40936729/matplotlib-title-spanning-two-or-any-number-of-subplot-columns

I found a possible way of solving this, but doesn't use the neat layout option of using gridspec:
https://stackoverflow.com/questions/27426668/row-titles-for-matplotlib-subplot?rq=1

In summary, I have a gridspec subplots layout within another gridspec. I do the plotting part in the inner grid and need the labeling flexibility in the outer grid. At the moment, using the current release of matplotlib, I can only achieve this using text annotations. Inbuilt functions (like supxlabel, supylabel, supxticklabels, supyticklabels, suptitle), for the outer grid, will be very useful.

@jklymak
Copy link
MemberAuthor

@mwaskom This is the suplabel PR. This doesn'treally require the other PR, but would be nice to do it after....

@mwaskom
Copy link

I'm afraid I don't know where to find it in the diff, but is the default font size here bigger than regular axes labels?

I'm not sure I've ever needed to add a "suplabel" pertaining to multiple axes that have existing, distinct labels. My use-case is almost always a situation where I have multiple subplots with shared axes and I want to add a single label to identify them. In that case, I'd want to the label to have the same size as a normal axis label.

Also, will these suplabels be tighter against the axes when there are no first-order labels?

I won't assert or claim to know which is a more common usecase, but I do think it's an application this PR should consider...

@jklymak
Copy link
MemberAuthor

I think they may be larger by default (just like suptitle) but the user can change this.

If there are no individual labels and you use constrained_layout the suplabels will be tight against the axes. Can likely be made to work with tight_layout as well. With no layout manager the whole thing is a bit of a mess anyhow.

As noted above, the suplables will be centered on the figure, not the spines or some other measure of what the label is supposed to span. That may or may not be acceptable depending on axes decorations, but it's a lot simpler.

@jklymakjklymakforce-pushed theenh-add-suplabels branch 2 times, most recently frome2d9131 toacc550aCompareOctober 10, 2020 04:06
@jklymakjklymak marked this pull request as ready for reviewOctober 10, 2020 04:16
@jklymak
Copy link
MemberAuthor

This is ready for review, and closes at least one feature request, and something seaborn would like.

@dopplershiftdopplershift added this to thev3.4.0 milestoneOct 14, 2020
@jklymakjklymakforce-pushed theenh-add-suplabels branch 2 times, most recently fromdfe0086 to2c51392CompareNovember 10, 2020 17:19
@jklymakjklymakforce-pushed theenh-add-suplabels branch 3 times, most recently frome5e4813 todfd9ed0CompareNovember 18, 2020 21:27
@jklymakjklymakforce-pushed theenh-add-suplabels branch 2 times, most recently fromb5a9247 to04b736fCompareNovember 18, 2020 21:29
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@dopplershift
Copy link
Contributor

Were we relying on Travis to run any unique test configurations? I'm wondering why test lines execute has dropped so much...

@QuLogic
Copy link
Member

Is it not posting? It seems to have run...

Not everything is installed in Azure Pipelines, so I don't think it covers the same things.

@dopplershift
Copy link
Contributor

Travis CI doesn't show up in the current list of checks on this PR. It looks like no PR builds have run in 3 days. I'm assuming we're running into the same thing that SciPy and NumPy have run into due to Travis changing their pricing model:

image

@QuLogic
Copy link
Member

Oh, I did not notice the date. I guess we'll put this back on the meeting agenda.

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

This is very nice looking!

I also really like the test images, they make it very clear what is going on.

@tacaswell
Copy link
Member

Anyone can merge on CI green.

@QuLogicQuLogic merged commitff15ca9 intomatplotlib:masterDec 3, 2020
@QuLogic
Copy link
Member

Code coverage is normal again, since this ran with GitHub Actions after@tacaswell's commit.

@jklymak
Copy link
MemberAuthor

Thanks for everyone's reviews, and for@QuLogic for fixing codecov!

orena1 reacted with thumbs up emoji

@jklymakjklymak deleted the enh-add-suplabels branchDecember 3, 2020 23:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@timhoffmtimhoffmtimhoffm left review comments

@tacaswelltacaswelltacaswell approved these changes

@QuLogicQuLogicQuLogic approved these changes

Assignees

No one assigned

Labels

topic: geometry managerLayoutEngine, Constrained layout, Tight layout

Projects

None yet

Milestone

v3.4.0

Development

Successfully merging this pull request may close these issues.

FR: add a supxlabel and supylabel as the suptitle function which are already exist

7 participants

@jklymak@timhoffm@sks-2020@mwaskom@dopplershift@QuLogic@tacaswell

[8]ページ先頭

©2009-2026 Movatter.jp