Skip to content

Commit aa51512

Browse files
committed
Remove outdated cartopy 0.17 stuff (fix #208)
1 parent 29db2b5 commit aa51512

File tree

1 file changed

+4
-34
lines changed

1 file changed

+4
-34
lines changed

proplot/axes/geo.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -797,47 +797,16 @@ def _init_gridlines(self):
797797
"""
798798
Create monkey patched "major" and "minor" gridliners managed by proplot.
799799
"""
800-
# Cartopy 0.18 monkey patch. This fixes issue where we get overlapping
801-
# gridlines on dateline. See the "nx -= 1" line in Gridliner._draw_gridliner
802-
# TODO: Submit cartopy PR. This is awful but necessary for quite a while if
803-
# the time between v0.17 and v0.18 is any indication.
804-
def _draw_gridliner(self, *args, **kwargs):
805-
result = type(self)._draw_gridliner(self, *args, **kwargs)
806-
if _version_cartopy >= '0.18':
807-
lon_lim, _ = self._axes_domain()
808-
if abs(np.diff(lon_lim)) == abs(np.diff(self.crs.x_limits)):
809-
for collection in self.xline_artists:
810-
if not getattr(collection, '_cartopy_fix', False):
811-
collection.get_paths().pop(-1)
812-
collection._cartopy_fix = True
813-
return result
814-
815-
# Cartopy < 0.18 monkey patch. This is part of filtering valid label coordinates
816-
# to values between lon_0 - 180 and lon_0 + 180.
800+
# Cartopy < 0.18 monkey patch. Helps filter valid coordates to lon_0 +/- 180
817801
def _axes_domain(self, *args, **kwargs):
818802
x_range, y_range = type(self)._axes_domain(self, *args, **kwargs)
819803
if _version_cartopy < '0.18':
820804
lon_0 = self.axes.projection.proj4_params.get('lon_0', 0)
821805
x_range = np.asarray(x_range) + lon_0
822806
return x_range, y_range
823-
824-
# Cartopy < 0.18 gridliner method monkey patch. Always print number in range
825-
# (180W, 180E). We choose #4 of the following choices (see Issue #120):
826-
# 1. lonlines go from -180 to 180, but get double 180 labels at dateline
827-
# 2. lonlines go from -180 to e.g. 150, but no lines from 150 to dateline
828-
# 3. lonlines go from lon_0 - 180 to lon_0 + 180 mod 360, but results
829-
# in non-monotonic array causing double gridlines east of dateline
830-
# 4. lonlines go from lon_0 - 180 to lon_0 + 180 monotonic, but prevents
831-
# labels from being drawn outside of range (-180, 180)
832-
def _add_gridline_label(self, value, axis, upper_end):
833-
if _version_cartopy < '0.18':
834-
if axis == 'x':
835-
value = (value + 180) % 360 - 180
836-
return type(self)._add_gridline_label(self, value, axis, upper_end)
807+
# Return the gridliner with monkey patch
837808
gl = self.gridlines(crs=ccrs.PlateCarree())
838-
gl._draw_gridliner = _draw_gridliner.__get__(gl) # apply monkey patch
839809
gl._axes_domain = _axes_domain.__get__(gl)
840-
gl._add_gridline_label = _add_gridline_label.__get__(gl)
841810
gl.xlines = gl.ylines = False
842811
self._toggle_gridliner_labels(gl, False, False, False, False, False)
843812
return gl
@@ -1068,7 +1037,8 @@ def _update_gridlines(
10681037
gl.ylines = latgrid
10691038
lonlines = self._get_lonticklocs(which=which)
10701039
latlines = self._get_latticklocs(which=which)
1071-
lonlines = (np.asarray(lonlines) + 180) % 360 - 180 # specific to _CartopyAxes
1040+
if _version_cartopy >= '0.18': # see lukelbd/proplot#208
1041+
lonlines = (np.asarray(lonlines) + 180) % 360 - 180 # only for cartopy
10721042
gl.xlocator = mticker.FixedLocator(lonlines)
10731043
gl.ylocator = mticker.FixedLocator(latlines)
10741044

0 commit comments

Comments
 (0)