Repository navigation
ENH: Added sharex/sharey string support to subplot_mosaic - #32437
nillohitroy wants to merge 8 commits into
Conversation
|
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. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Dear Maintainers, |
|
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.. |
|
Hi @iccir |
|
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 Rebase on the upstream branch
|
|
Hey, it happens - git can be tricky :) It looks like you made two commits: I'd do something like the following: Then I'd follow @rcomer's instructions above. You can always reapply the patch with: |
4f25789 to
1416ea3
Compare
|
If you get a test failure that you don't understand, there are several possibilities:
More commonly, however, #3 can indicate that something is wrong with the Continuous Integration (CI) system. You can often look at other pull requests to see if they are having similar issues. Python 3.12 on macOS 15 has been failing all day - here's another example with the same error. So, it's probably not an error in your code! |
I also have the same view as you. It is showing that the test is failing only in macos-15 (macos26 is running successfully). Also, I have tested the code locally as well, so I'm pretty confident about it. My request is if you could review my code so as to ensure if there are other major issues or this code can be merged to the repo.. |
|
Hi @rcomer |
…bels and updated docstrings
|
@timhoffm |
|
Hi @timhoffm |
|
Hi @timhoffm |
timhoffm
left a comment
There was a problem hiding this comment.
The test structure is good now.
The copilot comment is a valid point. What do we do about it?
#32437 (comment)
The issue is that my fix is quite incomplete in the sense that if instead of standard notations, the user uses scientific notations (The So, it's your call Captain. |
|
We should not ship an incomplete implementation. We actually have the semantics sort of available via Please check: That functionality is coded for regular grids and is not directly suitable for mosaic. Can one split this into (a) detecting whether an axis is "outer" and (b) applying the needed config to the axis. (a) is different for grids and mosaic; (b) may be reusable for both cases. |
There was a problem hiding this comment.
🟡 Changes recommended
A moderate regression causes shared polar mosaics to hide inner theta tick labels by bypassing the non-rectangular-axis guard, and the FigureBase API documentation also remains stale.
1 open issue
3 resolved since last review
Review effort: Lite
| behave as for `subplots`. If 'row', Axes that occupy the exact same row span | ||
| (the same vertical space in the grid) will share an x-axis (or y-axis). | ||
| If 'col', Axes that occupy the exact same column span (the same horizontal | ||
| space in the grid) will share an x-axis (or y-axis). If False or 'none', | ||
| each subplot's x- or y-axis will be independent. |
|
Hi @timhoffm |
|
Thank you @timhoffm |
|
Hi @nillohitroy. Code changes require two approving reviews so you'll need one more approval before this PR can be merged (which is handled by a maintainer). Your contribution is appreciated, but keep in mind that review capacity can sometimes be limited. |
|
Hi @lucaznch |


PR summary
This PR implements string arguments (
'all','row','col') and booleanTrue/Falseforsharexandshareyinsubplot_mosaic()for #18305 .To handle complex and nested layouts, the axes are grouped based on their specific
GridSpecand exactrowspan/colspancoordinates. Axes only share a row or column if their spans are identical.For example, consider a layout where C and D span both rows:
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()orax._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 themax()ofrowspan.stopacross just the group's members. It then loops through that group and appliesax.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