Skip to content

Commit 29b7d6d

Browse files
committed
Fix CartopyAxes.text() bug
1 parent 7132b40 commit 29b7d6d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

proplot/axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3277,7 +3277,7 @@ def _format_apply(self, patch_kw, lonlim, latlim, boundinglat,
32773277
# Checks
32783278
if (lonlim is not None or latlim is not None or
32793279
boundinglat is not None):
3280-
warnings.warn('Got lonlim={lonlim}, latlim={latlim}, boundinglat={boundinglat}, but you cannot "zoom into" a basemap projection after creating it. Pass a proj_kw dictionary in your call to subplots, with any of the following basemap keywords: boundinglat, llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, llcrnrx, llcrnry, urcrnrx, urcrnry, width, or height.')
3280+
warnings.warn(f'Got lonlim={lonlim!r}, latlim={latlim!r}, boundinglat={boundinglat!r}, but you cannot "zoom into" a basemap projection after creating it. Pass a proj_kw dictionary in your call to subplots, with any of the following basemap keywords: boundinglat, llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, llcrnrx, llcrnry, urcrnrx, urcrnry, width, or height.')
32813281

32823282
# Map boundary
32833283
# * First have to *manually replace* the old boundary by just

proplot/wrappers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,13 +1145,21 @@ def violinplot_wrapper(self, func, *args,
11451145

11461146
def _get_transform(self, transform):
11471147
"""Translates user input transform. Also used in an axes method."""
1148-
if isinstance(transform, mtransforms.Transform):
1148+
try:
1149+
from cartopy.crs import CRS
1150+
except ModuleNotFoundError:
1151+
CRS = None
1152+
cartopy = (getattr(self, 'name', '') == 'cartopy')
1153+
if (isinstance(transform, mtransforms.Transform)
1154+
or CRS and isinstance(transform, CRS)):
11491155
return transform
11501156
elif transform == 'figure':
11511157
return self.figure.transFigure
11521158
elif transform == 'axes':
11531159
return self.transAxes
11541160
elif transform == 'data':
1161+
return PlateCarree() if cartopy else self.transData
1162+
elif cartopy and transform == 'map':
11551163
return self.transData
11561164
else:
11571165
raise ValueError(f'Unknown transform {transform!r}.')

0 commit comments

Comments
 (0)