Skip to content

Conversation

@cvanelteren
Copy link
Collaborator

Addresses #155 and #158

@cvanelteren
Copy link
Collaborator Author

Note: Tests will fail on added tests.

@cvanelteren cvanelteren changed the title Feat shared geo new [Feature addd] Share Axes in GeoPlot + bug fixes Apr 14, 2025
@codecov
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

❌ Patch coverage is 95.36153% with 34 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/axes/geo.py 90.03% 13 Missing and 15 partials ⚠️
ultraplot/figure.py 95.08% 1 Missing and 2 partials ⚠️
ultraplot/tests/test_geographic.py 99.02% 0 Missing and 2 partials ⚠️
ultraplot/axes/base.py 94.73% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren cvanelteren marked this pull request as draft April 16, 2025 10:52
@cvanelteren cvanelteren changed the title [Feature addd] Share Axes in GeoPlot + bug fixes [Feature add] Share Axes in GeoPlot + bug fixes Apr 16, 2025
@cvanelteren cvanelteren requested review from beckermr and Copilot April 16, 2025 19:59
Copy link
Contributor

Copilot AI left a comment

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 adds a feature to share axes on geographic plots and includes bug fixes related to axis sharing and test configuration.

  • Adds tests for validating shared geographic tick configurations.
  • Refactors axis sharing logic in GeoAxes and related modules.
  • Removes extraneous debug prints in test configuration.

Reviewed Changes

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

Show a summary per file
File Description
ultraplot/tests/test_geographic.py Adds new tests for geographic ticks and shared axis behavior
ultraplot/tests/conftest.py Removes debug print statements from test failure handling
ultraplot/figure.py Updates subplot creation and axis sharing logic for GeoAxes
ultraplot/axes/shared.py Adjusts share function signatures and minor ticker handling
ultraplot/axes/geo.py Extensive refactor for GeoAxes: sharing, toggling ticks and gridliner labels
ultraplot/axes/base.py Adds an _unshare method and a guard for NaN padding values
Comments suppressed due to low confidence (1)

ultraplot/axes/geo.py:1780

  • [nitpick] Consider renaming the loop variable 'object' to something like 'obj' to avoid shadowing the built-in 'object'.
for object in objects:

@cvanelteren
Copy link
Collaborator Author

Will add more tests tomorrow for codecov but it's looking good locally with a few plots showing different sizes but otherwise have high visual fidelity. Opening this up for review.

@cvanelteren cvanelteren marked this pull request as ready for review May 10, 2025 07:54
@cvanelteren cvanelteren requested a review from beckermr May 10, 2025 07:54
Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

I took a closer look at the image test failure:

Here is the code:

@pytest.mark.mpl_image_compare
def test_geoticks():

    lonlim = (-140, 60)
    latlim = (-10, 50)
    basemap_projection = uplt.Proj(
        "cyl",
        lonlim=lonlim,
        latlim=latlim,
        backend="basemap",
    )
    fig, ax = uplt.subplots(
        ncols=3,
        proj=(
            "cyl",  # cartopy
            "cyl",  # cartopy
            basemap_projection,  # basemap
        ),
        share=0,
    )
    settings = dict(land=True, labels=True, lonlines=20, latlines=20)
    # Shows sensible "default"; uses cartopy backend to show the grid lines with ticks
    ax[0].format(
        lonlim=lonlim,
        latlim=latlim,
        **settings,
    )

    # Add lateral ticks only
    ax[1].format(
        latticklen=True,
        gridminor=True,
        lonlim=lonlim,
        latlim=latlim,
        **settings,
    )

    ax[2].format(
        latticklen=5.0,
        lonticklen=2.0,
        grid=False,
        gridminor=False,
        **settings,
    )
    return fig

Here is a zoom of the middle panel (top is baseline, bottom is this PR):

Screenshot 2025-05-10 at 6 20 16 AM

It appears that the call to set latlim for the middle panel is now being ignored in the new version of the code in this PR. This is definitely a bug. I don't see why latlim should now be ignored.

@cvanelteren
Copy link
Collaborator Author

Fixed @beckermr :

image

@cvanelteren
Copy link
Collaborator Author

Not sure why the ticks are not using the full range but I cut off the edges here and it looks the same.

@cvanelteren cvanelteren requested a review from beckermr May 10, 2025 14:50
@cvanelteren
Copy link
Collaborator Author

weirdly enough when I do this for the basemap the yticks behave strangely. Only one appears.

Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

Two more items. Thank you so much for the good work on this PR!

Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

LGTM! Great work on this PR!

@cvanelteren
Copy link
Collaborator Author

Will draft an appropriate release to 1.5. Lots of new features 😄

@cvanelteren cvanelteren enabled auto-merge (squash) May 11, 2025 10:15
@cvanelteren cvanelteren disabled auto-merge May 11, 2025 10:16
@cvanelteren cvanelteren merged commit e6b1bc6 into Ultraplot:main May 11, 2025
9 of 10 checks passed
cvanelteren added a commit that referenced this pull request Aug 14, 2025
- Added ability to share GeoAxes
- Fixed numerous bugs regarding ticks on GeoAxes
- Backend allows for sharing and unsharing axes.

---------

Co-authored-by: Matthew R. Becker <beckermr@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants