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

Use boundary to compute axes domain in gridliner #1538

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/cartopy/mpl/gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,18 @@ def _axes_domain(self, nx=None, ny=None):
ax_transform = self.axes.transAxes
desired_trans = ax_transform - transform

nx = nx or 100
ny = ny or 100
nx = nx or 101
ny = ny or 101
x = np.linspace(1e-9, 1 - 1e-9, nx)
y = np.linspace(1e-9, 1 - 1e-9, ny)
x, y = np.meshgrid(x, y)

coords = np.column_stack((x.ravel(), y.ravel()))
xyp = (self.axes.patch.get_transform()-ax_transform).transform(
self.axes.patch.get_path().vertices)
x = np.concatenate((x.ravel(), xyp[:, 0]))
y = np.concatenate((y.ravel(), xyp[:, 1]))

coords = np.column_stack((x, y))

in_data = desired_trans.transform(coords)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion lib/cartopy/tests/mpl/test_gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
@pytest.mark.natural_earth
@ImageTesting(['gridliner1'],
# Robinson projection is slightly better in Proj 6+.
tolerance=0.7 if ccrs.PROJ4_VERSION >= (6, 0, 0) else 0.5)
tolerance=0.7 if ccrs.PROJ4_VERSION >= (6, 0, 0) else 0.62)
def test_gridliner():
ny, nx = 2, 4

Expand Down Expand Up @@ -112,6 +112,13 @@ def test_gridliner():
top=1 - delta, bottom=0 + delta)


@ImageTesting(['gridliner_orthographic'])
def test_gridliner_orthographic():
plt.figure(figsize=(4, 4))
ax = plt.subplot(111, projection=ccrs.Orthographic())
ax.gridlines(ccrs.PlateCarree())


def test_gridliner_specified_lines():
meridians = [0, 60, 120, 180, 240, 360]
parallels = [-90, -60, -30, 0, 30, 60, 90]
Expand Down