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

Incorrect behavior of GridLiner when setting draw_labels='x' #2372

Open
jshn9515 opened this issue Apr 17, 2024 · 0 comments
Open

Incorrect behavior of GridLiner when setting draw_labels='x' #2372

jshn9515 opened this issue Apr 17, 2024 · 0 comments

Comments

@jshn9515
Copy link

Description

I attempted to create a NorthPolarStereo projection where only the x-axis label is visible. However, when I set draw_labels='x', both the x and y-axis labels are displayed. Under closer inspection, I discovered that the logic for determining whether to draw the label is unclear. Within the GridLliner class, when auto_inline=True, self.inline_labels is always set to the specific coordinate, regardless of the draw_labels setting. This result causes in incorrect behavior to _draw_this_label function.

Code to reproduce

import numpy as np
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import matplotlib.path as mpath

fig = plt.figure(1)
ax = fig.add_subplot(projection=ccrs.NorthPolarStereo())
ax.set_extent([-180, 180, 0, 90], crs=ccrs.PlateCarree())
ax.add_feature(cfeature.LAND.with_scale('110m'))
theta = np.linspace(0, 2 * np.pi, 100)
center = [0.5, 0.5]
radius = 0.5
verts = np.vstack([np.sin(theta), np.cos(theta)]).T
circle = mpath.Path(verts * radius + center)
ax.set_boundary(circle, transform=ax.transAxes)
ax.gridlines(draw_labels='x', xlocs=np.arange(-180, 210, 30), rotate_labels=False,
             ylocs=np.arange(0, 90, 20), linestyle=':', color='black')
plt.show()

Cartopy version

0.23.0

This is the display figure

Figure_1

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