Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: use compound paths to draw transformed geometries #2325

Merged
merged 1 commit into from
Feb 10, 2024

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented Feb 9, 2024

Rationale

When a geometry gets transformed to a different crs, it can become multiple geometries. Currently we plot these as separate paths which could be problematic if the user passes a list of e.g. facecolors.

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import shapely.geometry as sgeom

square1 = sgeom.Polygon([(-10, -10), (10, -10), (10, 10), (-10, 10), (-10, 10) ])
square2 = sgeom.Polygon([(30, 0), (50, 0), (50, 20), (30, 20), (30, 0)])

fig = plt.figure(figsize=(4, 5))

ax1 = fig.add_subplot(211, projection=ccrs.PlateCarree())
ax2 = fig.add_subplot(212, projection=ccrs.PlateCarree(central_longitude=180))

for ax in ax1, ax2:
    ax.coastlines()
    ax.add_geometries([square1, square2], crs=ccrs.PlateCarree(),
                      facecolors=['r', 'b'])

plt.show()

Before:
image

After:
image

Implications

@@ -585,7 +585,7 @@ def test_pcolormesh_set_clim_with_mask():

@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(filename='pcolormesh_limited_area_wrap.png',
tolerance=1.82)
tolerance=1.83)
Copy link
Member Author

Choose a reason for hiding this comment

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

Diff looks like
temp

@greglucas greglucas merged commit a136876 into SciTools:main Feb 10, 2024
22 checks passed
@rcomer rcomer deleted the geoms-compound-path branch February 10, 2024 16:47
@QuLogic QuLogic added this to the Next Release milestone Feb 12, 2024
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.

3 participants