Skip to content

Commit ad235aa

Browse files
committed
Fix lonlines bug
1 parent 29b7d6d commit ad235aa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

proplot/axes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,6 +2758,7 @@ def format(self, *,
27582758
Passed to `Axes.format` and `Axes.context`.
27592759
"""
27602760
# Parse alternative keyword args
2761+
# TODO: Why isn't default latmax 80 respected sometimes?
27612762
context, kwargs = self.context(**kwargs)
27622763
with context:
27632764
lonlines = _notNone(lonlines, lonlocator, rc['geogrid.lonstep'], names=('lonlines', 'lonlocator'))
@@ -2772,6 +2773,9 @@ def format(self, *,
27722773
# Longitude gridlines, draw relative to projection prime meridian
27732774
# NOTE: Always generate gridlines array at least on first format call
27742775
# because rc setting will be not None
2776+
# NOTE: Cartopy seems to need longitude lines to fall within
2777+
# -180 and 180. Also if they are not circular, latitude lines will
2778+
# not extend across entire sphere.
27752779
if isinstance(self, CartopyAxes):
27762780
lon_0 = self.projection.proj4_params.get('lon_0', 0)
27772781
else:
@@ -2780,6 +2784,9 @@ def format(self, *,
27802784
if lonlines is not None:
27812785
if not np.iterable(lonlines):
27822786
lonlines = utils.arange(lon_0 - 180, lon_0 + 180, lonlines)
2787+
lonlines = (np.array(lonlines) + 180) % 360 - 180
2788+
if lonlines[0] == lonlines[-1]:
2789+
lonlines[-1] += 360
27832790
lonlines = [*lonlines]
27842791

27852792
# Latitudes gridlines, draw from -latmax to latmax unless result would

0 commit comments

Comments
 (0)