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

Spines form incomplete junctions with some projections #2184

Closed
kerrycobb opened this issue Jun 5, 2023 · 3 comments · Fixed by #2186
Closed

Spines form incomplete junctions with some projections #2184

kerrycobb opened this issue Jun 5, 2023 · 3 comments · Fixed by #2186
Milestone

Comments

@kerrycobb
Copy link

kerrycobb commented Jun 5, 2023

Description

When using certain projections such as cartopy.crs.AlbersEqualArea or cartopy.crs.Orthographic along with changing the extent such that some of the map is clipped, the spines at one corner do not form a connection or properly align. This is evident if you increase the line width of the spines. The image below shows the result in the affected corner which I have observed to be in both the top right corner as well as the lower left corner. The code below produced the plot this image was taken from.
Example

Code to reproduce

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

fig = plt.figure()
ax = plt.axes(projection=ccrs.Orthographic(0, 0))
ax.set_extent([-10, -11, 10, 11])
ax.spines[:].set_linewidth(3)
plt.savefig("test.pdf")
Full environment definition

Operating system

macOS 11.3.1

Versions

Cartopy: 0.21.1
matplotlib: 3.7.1

@greglucas
Copy link
Contributor

It looks like the GeoSpine path isn't closed. @QuLogic do you know if there was a specific reason for not closing the path? It looks like you explicitly set the capstyle to "butt" in #1213
I suppose non-closure makes sense for normal Left/Right/Bottom/Top Spines, but are GeoSpines always loops and therefore closed?

@kerrycobb A workaround for your specific case, but I don't think is general, is to call ax.spines[:].set_capstyle("projecting").

@kerrycobb
Copy link
Author

Thanks @greglucas for the work around! That's a good solution for my current case.

I was thinking the same thing about the path not being closed because of the effect that I see if I set the joinstyle to round ax.spines[:].set_joinstyle("round"). It changes the joinstyle of just 3 corners.

@QuLogic
Copy link
Member

QuLogic commented Jun 6, 2023

I think that was just to match previous behaviour; the former PathPatch uses 'butt' cap style. Matplotlib's spines use 'projecting', so that would likely be more consistent. I would think that not closing the path is an oversight, but since that's used for the background as well, I'm a bit surprised that didn't seem to cause any other issues.

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 a pull request may close this issue.

3 participants