diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py index d63d7150f..4f13b4f5c 100644 --- a/lib/cartopy/mpl/geoaxes.py +++ b/lib/cartopy/mpl/geoaxes.py @@ -306,7 +306,12 @@ def wrapper(self, *args, **kwargs): transform = kwargs.get('transform', None) if transform is None: transform = self.projection - if (isinstance(transform, ccrs.CRS) and + # Raise an error if any of these functions try to use + # a spherical source CRS. + non_spherical_funcs = ['contour', 'contourf', 'pcolormesh', 'pcolor', + 'quiver', 'barbs', 'streamplot'] + if (func.__name__ in non_spherical_funcs and + isinstance(transform, ccrs.CRS) and not isinstance(transform, ccrs.Projection)): raise ValueError('Invalid transform: Spherical {} ' 'is not supported - consider using ' @@ -501,11 +506,12 @@ def draw(self, renderer=None, **kwargs): # caching the resulting image; # buffering the result by 10%...; if not self._done_img_factory: - for factory, args, kwargs in self.img_factories: + for factory, factory_args, factory_kwargs in self.img_factories: img, extent, origin = factory.image_for_domain( - self._get_extent_geom(factory.crs), args[0]) + self._get_extent_geom(factory.crs), factory_args[0]) self.imshow(img, extent=extent, origin=origin, - transform=factory.crs, *args[1:], **kwargs) + transform=factory.crs, *factory_args[1:], + **factory_kwargs) self._done_img_factory = True return matplotlib.axes.Axes.draw(self, renderer=renderer, **kwargs)