diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py index f6a3be59b..b3a822367 100644 --- a/lib/cartopy/mpl/geoaxes.py +++ b/lib/cartopy/mpl/geoaxes.py @@ -1893,7 +1893,7 @@ def _wrap_quadmesh(self, collection, **kwargs): "It is recommended to remove the wrap manually " "before calling pcolormesh.") # With gouraud shading, we actually want an (Ny, Nx) shaped mask - gmask = np.zeros(data_shape, dtype=bool) + gmask = np.zeros((data_shape[0], data_shape[1]), dtype=bool) # If any of the cells were wrapped, apply it to all 4 corners gmask[:-1, :-1] |= mask gmask[1:, :-1] |= mask diff --git a/lib/cartopy/tests/mpl/test_mpl_integration.py b/lib/cartopy/tests/mpl/test_mpl_integration.py index 2e65d63d0..400be6828 100644 --- a/lib/cartopy/tests/mpl/test_mpl_integration.py +++ b/lib/cartopy/tests/mpl/test_mpl_integration.py @@ -654,6 +654,17 @@ def test_pcolormesh_single_column_wrap(): return fig +def test_pcolormesh_wrap_gouraud_shading_failing_mask_creation(): + x_range = np.linspace(-180, 180, 50) + y_range = np.linspace(90, -90, 50) + x, y = np.meshgrid(x_range, y_range) + data = ((np.sin(np.deg2rad(x))) / 10. + np.exp(np.cos(np.deg2rad(y)))) + + fig = plt.figure(figsize=(10, 6)) + ax = fig.add_subplot(1, 1, 1, projection=ccrs.Mercator()) + ax.pcolormesh(x, y, data, transform=ccrs.PlateCarree(), shading='gouraud') + + def test_pcolormesh_diagonal_wrap(): # Check that a cell with the top edge on one side of the domain # and the bottom edge on the other gets wrapped properly