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

Setting the x coordinate of inline latitude labels with non PlateCarree projections #2498

Open
vikasnataraja opened this issue Feb 17, 2025 · 0 comments

Comments

@vikasnataraja
Copy link

vikasnataraja commented Feb 17, 2025

Is there an option to change the default x or longitude positions of inline latitude labels, particularly when using projections like Orthographic? Here's an example of what the current behavior is:

fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(projection=ccrs.Orthographic(200, 67))
gl = ax.gridlines(draw_labels=True, y_inline=True, x_inline=False)
ax.add_feature(cartopy.feature.OCEAN)
# disable set extent for now
# ax.set_extent([170, 215, 58, 75], crs=ccrs.PlateCarree()) 
plt.show()

which results in this figure as expected:

Image

The issue of inline latitude placement becomes noticeable when an extent is applied to zoom in using, for example, ax.set_extent([170, 215, 58, 75], crs=ccrs.PlateCarree()) which then produces this image:

Image

The latitude labels go missing, essentially, because they are placed on the 90/-90 meridian (which I found via gl.label_artists). There are a couple of workarounds on StackOverflow like this one here but they didn't work for me and they seem like temporary fixes anyway. Is there a way to set the x coordinate of the latitude labels when they are inline, ideally regardless of if the extent is set or not? I'm not sure if this is also an issue with other projections or just the Orthographic.

Package versions

Python == 3.11.11
numpy == 1.26.0
matplotlib == 3.9.2
cartopy == 0.23.0

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

No branches or pull requests

1 participant