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

Fix label_outer in the presence of colorbars.#30098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
anntzer wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromanntzer:locb

Conversation

anntzer
Copy link
Contributor

The subgridspec to be considered should be the one containing both the axes and the colorbar, not the sub-subgridspec of just the axes.

Closes#27305 (using#27305 (comment) and a test).

PR summary

PR checklist

@anntzeranntzer added topic: geometry managerLayoutEngine, Constrained layout, Tight layout topic: color/colorbar labelsMay 23, 2025
@github-actionsgithub-actionsbot added topic: axes and removed topic: geometry managerLayoutEngine, Constrained layout, Tight layout labelsMay 23, 2025
return
gs = ss.get_gridspec()
if (isinstance(gs, mpl.gridspec.GridSpecFromSubplotSpec)
and gs.nrows * gs.ncols == 6):
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment what this magic is about.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

done

Copy link
Member

@timhoffmtimhoffmMay 23, 2025
edited
Loading

Choose a reason for hiding this comment

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

Thanks. Basically ok.

Would it make more sense thatmake_axes_gridspec explicitly flags the gridspec? Not sure what the right level of explicitness / specialization is, but it feels awkward to detect a gridspec for the colorbar thrugh nrows * ncols. Options could be (from less to more formal):

  • monkey-patch_is_colorbar_gridspec onto the gridspec, so that we can testif hasattr(gs, "_is_colorbar_gridspec")
  • add a_is_colorbar_gridspec attribute to all gridspecs, so that we can testif gs._is_colorbar_gridspec
  • Create aColorbarGridSpec subclass so that we can testif isinstance(gs, ColorbarGridSpec)

Copy link
Member

Choose a reason for hiding this comment

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

I would lean towards the least formal here - the subgridspec trick of making colorbars is pretty clunky, and note that it is explicitlynot used bylayout='constrained'.

The original ideas behind grid specs and subgridspecs were very good, but unfortunately loses the relationship between sibling axes if you change add the colorbar and make the colorbar and main axes child subgridspecs.

The subgridspec to be considered should be the one containing both theaxes and the colorbar, not the sub-subgridspec of just the axes.
f, axs = plt.subplots(2, 2, sharex=True, sharey=True)
@pytest.mark.parametrize('with_colorbar', [True, False])
def test_label_outer(remove_ticks, with_colorbar):
fig, axs = plt.subplots(2, 2, sharex=True, sharey=True)
Copy link
Member

Choose a reason for hiding this comment

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

Can this get tested with layout=constrained as well?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

@timhoffmtimhoffmtimhoffm left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]: Axes.label_outer() does not work when there is a colorbar
3 participants
@anntzer@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp