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

ENH: Added sharex/sharey string support to subplot_mosaic by nillohitroy · Pull Request #32437 · matplotlib/matplotlib · GitHub

Repository navigation

ENH: Added sharex/sharey string support to subplot_mosaic - #32437

Open
nillohitroy wants to merge 11 commits into
matplotlib:mainfrom
nillohitroy:subplot_mosaic-share-issue-18305
Open

nillohitroy wants to merge 11 commits into
matplotlib:mainfrom
nillohitroy:subplot_mosaic-share-issue-18305

Conversation

Copy link
Copy Markdown

PR summary

This PR implements string arguments ('all', 'row', 'col') and boolean True/False for sharex and sharey in subplot_mosaic() for #18305 .

To handle complex and nested layouts, the axes are grouped based on their specific GridSpec and exact rowspan/colspan coordinates. Axes only share a row or column if their spans are identical.
For example, consider a layout where C and D span both rows:

ABCD
EFCD

If sharey='row' is passed, the code forms three isolated sharing groups based on their vertical spans:

  • [A, B] (Row 0)
  • [E, F] (Row 1)
  • [C, D] (Spanning Rows 0 and 1)

Once the groups are isolated, the logic designates the first axis in each list as the parent and calls standard .sharex(parent) or .sharey(parent) on the remaining children in that specific group.

Important Note: Relying on Matplotlib's global ax._label_outer_xaxis() or ax._label_outer_yaxis() inadvertently hid tick labels for inner subplots if they formed their own isolated sharing group. For this very reason, I implemented a custom logic which calculates label visibility dynamically per group. For example, in an X-axis sharing group, it calculates the physical bottom edge by finding the max() of rowspan.stop across just the group's members. It then loops through that group and applies ax.tick_params(labelbottom=False) to any axis sitting above that localized bottom edge.

AI Disclosure

I have used Generative AI to understand the codebase (specifically the code for the issue), setting up of the environment (installing packages and dependencies required), the intent of the issue and to get to the center of the problem. It is also important to mention that AI was used to understand the requirements of the maintainers and how #32239 failed and what to avoid while coding.

Verification

I have tested the code for a local matplotlib development build, running it on my system and creating a sample plot for a sample data. Also, I have written some test cases for the same by trying to incorporate as many test cases as possible (5), all of which successfully passed.

I would be happy for any feedback regarding any portion of the code!!

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • New features and API changes have release notes
  • Documentation complies with general and docstring guidelines

Copilot AI balanced review requested due to automatic review settings October 4, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

Copy link
Copy Markdown
Author

Dear Maintainers,
I have seen how diligently you guys work and how mentally constraining reviewing each line of the code is. Though this issue is a 'good first issue' and not as complex (and may be not as important) as compared to the other bug fixes that the contributors are providing. I would be obliged if you could review my code and give me necessary feedback to improve it as much as possible.

iccir commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Assuming that I'm talking to an actual human: this PR is currently failing to pass the Linting and MyPy Stubtest checks. The AppVeyor build failure is somewhat expected as AppVeyor has been flaky recently.

Generally, you will want to make sure that all checks pass on any PR that you open to a repository. You need to get at least Linting and the stub test to pass first.

Copy link
Copy Markdown
Author

Assuming that I'm talking to an actual human: this PR is currently failing to pass the Linting and MyPy Stubtest checks. The AppVeyor build failure is somewhat expected as AppVeyor has been flaky recently.

Generally, you will want to make sure that all checks pass on any PR that you open to a repository. You need to get at least Linting and the stub test to pass first.

Thank you sir.. on it..

github-actions Bot added topic: geometry manager LayoutEngine, Constrained layout, Tight layout topic: rcparams Documentation: devdocs files in doc/devel labels Oct 7, 2026

Copy link
Copy Markdown
Author

Hi @iccir
I think I have screwed up in some way. Thing is, I have done a pull request and merged the code, so instead of just 1 commit, there is 11 commits and also some failed tests (of other developers). I have checked my tests (linting and all) and everything is successful. My question is: will everything work or do I have to open a new pull request?
Sorry for any trouble I have caused.

rcomer commented Oct 7, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

I think a rebase should sort that out. Assuming you have set the upstream remote as described here, try this:

Make a backup branch in case something else goes wrong

git branch my-backup-branch 

Rebase on the upstream branch

git fetch upstream
git rebase upstream/main

git push will then fail, but you can

git push --force-with-lease

iccir commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Hey, it happens - git can be tricky :)

It looks like you made two commits:
c278400
a14df4f

I'd do something like the following:

git diff \
    c278400dee9b6758ce74f0eab9b5cbc085b595ee^ \
    a14df4f320b0b13ebdf7fc34cf4d356e5f0f67ea > \
    /someplace/safe/changes.patch

Then I'd follow @rcomer's instructions above. You can always reapply the patch with:

git apply /someplace/safe/changes.patch

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL