Skip to content

Commit

Permalink
Merge pull request #1980 from greglucas/geoaxes-projection-kw
Browse files Browse the repository at this point in the history
  • Loading branch information
dopplershift authored Aug 23, 2022
2 parents 324325a + 8000376 commit 6f8f1a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/miscellanea/axes_grid_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def sample_data_3d(shape):
def main():
projection = ccrs.PlateCarree()
axes_class = (GeoAxes,
dict(map_projection=projection))
dict(projection=projection))

lons, lats, times, data = sample_data_3d((6, 73, 145))

Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ def _repr_html_(self):

def _as_mpl_axes(self):
import cartopy.mpl.geoaxes as geoaxes
return geoaxes.GeoAxes, {'map_projection': self}
return geoaxes.GeoAxes, {'projection': self}

def project_geometry(self, geometry, src_crs=None):
"""
Expand Down
24 changes: 15 additions & 9 deletions lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,22 @@ def __init__(self, *args, **kwargs):
Parameters
----------
map_projection: optional
The target :class:`~cartopy.crs.Projection` of this Axes object.
All other args and keywords are passed through to
:class:`matplotlib.axes.Axes`.
projection : cartopy.crs.Projection
The target projection of this Axes.
"""
if "map_projection" in kwargs:
warnings.warn("The `map_projection` keyword argument is "
"deprecated, use `projection` to instantiate a "
"GeoAxes instead.")
projection = kwargs.pop("map_projection")
else:
projection = kwargs.pop("projection")

"""
self.projection = kwargs.pop('map_projection')
"""The :class:`cartopy.crs.Projection` of this GeoAxes."""
# The :class:`cartopy.crs.Projection` of this GeoAxes.
if not isinstance(projection, ccrs.Projection):
raise ValueError("A GeoAxes can only be created with a "
"projection of type cartopy.crs.Projection")
self.projection = projection

super().__init__(*args, **kwargs)
self._gridliners = []
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/tests/mpl/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Test_Axes_add_geometries:
@mock.patch('cartopy.feature.ShapelyFeature')
def test_styler_kwarg(self, ShapelyFeature, add_feature_method):
ax = GeoAxes(plt.figure(), [0, 0, 1, 1],
map_projection=ccrs.Robinson())
projection=ccrs.Robinson())
ax.add_geometries(mock.sentinel.geometries, mock.sentinel.crs,
styler=mock.sentinel.styler, wibble='wobble')

Expand Down

0 comments on commit 6f8f1a7

Please sign in to comment.