Skip to content

Ensure that shared labels are consistently updated. - #177

Merged
beckermr merged 14 commits into
Ultraplot:mainfrom
cvanelteren:fix-labelloc-consistency
Apr 28, 2025
Merged

beckermr merged 14 commits into
Ultraplot:mainfrom
cvanelteren:fix-labelloc-consistency

Conversation

@cvanelteren

@cvanelteren cvanelteren commented Apr 25, 2025 •

Copy link
Copy Markdown
Collaborator

Fixes #176

Details code
   import ultraplot as uplt, numpy as np

layout = [
    [1, 2, 0],
    [1, 2, 5],
    [3, 4, 5],
    [3, 4, 0],
]
fig, ax = uplt.subplots(layout)

ax.format(
    xticklabelloc="t",
    yticklabelloc="r",
)

layout = [
    [1, 0, 2],
    [0, 3, 0],
    [4, 0, 5],
]

fig, ax = uplt.subplots(layout)
ax.format(
    xticklabelloc="t",
    yticklabelloc="r",
)
uplt.show(block=True)

will now be correct:

image

@cvanelteren

Copy link
Copy Markdown
Collaborator Author

What I don't like about this fix is that it will fool mpl by turning the sharex/y to None. I need to add a way to check for this to turn this back on automatically to prevent a potential edge case to be hit (not sure which).

@codecov

codecov Bot commented Apr 25, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.26923% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/figure.py 80.55% 4 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren
cvanelteren marked this pull request as draft April 25, 2025 09:34
@cvanelteren

cvanelteren commented Apr 25, 2025 •

Copy link
Copy Markdown
Collaborator Author

[x] Need to handle non trivial layout

@cvanelteren
cvanelteren force-pushed the fix-labelloc-consistency branch from 474a2e7 to e63b763 Compare April 25, 2025 12:32
@cvanelteren
cvanelteren requested a review from Copilot April 25, 2025 12:32

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.

Pull Request Overview

This PR addresses issue #176 by ensuring that shared axis labels are consistently updated across subplots. Key changes include:

  • Adding two new test cases in tests/test_axes.py to verify proper shared label behavior.
  • Introducing a new helper method _get_border_axes in figure.py for identifying boundary axes.
  • Updating axes sharing logic in axes/cartesian.py to correctly handle tick label visibility on border axes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ultraplot/tests/test_axes.py New test cases to validate shared label consistency.
ultraplot/figure.py Added _get_border_axes to retrieve border axes in various layouts.
ultraplot/axes/cartesian.py Modified the shared axes tick label update logic.

Comment thread ultraplot/axes/cartesian.py Resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@cvanelteren
cvanelteren marked this pull request as ready for review April 25, 2025 12:33
@beckermr beckermr self-assigned this Apr 25, 2025
@beckermr
beckermr self-requested a review April 25, 2025 19:19

@beckermr beckermr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The tests here should be used to generate an image comparison plot.

Comment thread ultraplot/tests/test_axes.py Resolved
Comment thread ultraplot/tests/test_axes.py Resolved
@beckermr

Copy link
Copy Markdown
Collaborator

An image comparison test is failing, but the artifact has no images in it to look at. I think this is a bug.

@cvanelteren

Copy link
Copy Markdown
Collaborator Author

I am actually tending to use less of the pytest-mpl if possible. These tests take much longer too complete than regular pytests. Currently, the test suite runs over 12 minutes I believe, which is rather long. I think we should move to more selectivel visual tests that benchmark the visual output to reduce the test running times.

@cvanelteren

Copy link
Copy Markdown
Collaborator Author

Need to fix the edgecase where it is not doing this for alt/twin axes.

@cvanelteren
cvanelteren marked this pull request as draft April 26, 2025 11:15
@cvanelteren

Copy link
Copy Markdown
Collaborator Author

Note that for twinned axes if set manually this would be the output:

image

This has twinx and twiny set for ax[1] (top right). Not sure if bug or feature.

@cvanelteren
cvanelteren marked this pull request as ready for review April 27, 2025 09:57
@cvanelteren
cvanelteren requested a review from beckermr April 27, 2025 09:58
@cvanelteren
cvanelteren dismissed beckermr’s stale review April 27, 2025 10:13

ready for review

@beckermr
beckermr merged commit f75018b into Ultraplot:main Apr 28, 2025
@cvanelteren
cvanelteren deleted the fix-labelloc-consistency branch April 28, 2025 07:25
cvanelteren added a commit to cvanelteren/ultraplot that referenced this pull request Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconistent formatting when setting labelloc for shared axes

3 participants