Skip to content

Commit ebf5067

Browse files
committed
do not try to fix wrap-around for scatter
1 parent 650f14d commit ebf5067

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ def with_transform(self,x,y,data,*args,**kwargs):
526526
# shift data to map projection region for
527527
# cylindrical and pseudo-cylindrical projections.
528528
if self.projection in _cylproj or self.projection in _pseudocyl:
529-
x, data = self.shiftdata(x, data)
529+
x, data = self.shiftdata(x, data,
530+
fix_wrap_around=plotfunc.__name__ not in ["scatter"])
530531
# convert lat/lon coords to map projection coords.
531532
x, y = self(x,y)
532533
return plotfunc(self,x,y,data,*args,**kwargs)
@@ -544,7 +545,7 @@ def with_transform(self,x,y,*args,**kwargs):
544545
# cylindrical and pseudo-cylindrical projections.
545546
if self.projection in _cylproj or self.projection in _pseudocyl:
546547
if x.ndim == 1:
547-
x = self.shiftdata(x)
548+
x = self.shiftdata(x, fix_wrap_around=plotfunc.__name__ not in ["scatter"])
548549
elif x.ndim == 0:
549550
if x > 180:
550551
x = x - 360.
@@ -4722,7 +4723,7 @@ def _ax_plt_from_kw(self, kw):
47224723
_ax = plt.gca()
47234724
return _ax, plt
47244725

4725-
def shiftdata(self,lonsin,datain=None,lon_0=None):
4726+
def shiftdata(self,lonsin,datain=None,lon_0=None,fix_wrap_around=True):
47264727
"""
47274728
Shift longitudes (and optionally data) so that they match map projection region.
47284729
Only valid for cylindrical/pseudo-cylindrical global projections and data
@@ -4745,6 +4746,10 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
47454746
datain original 1-d or 2-d data. Default None.
47464747
lon_0 center of map projection region. Defaut None,
47474748
given by current map projection.
4749+
fix_wrap_around if True try to shift longitudes (and data) to correctly
4750+
display the array in the selected projection. If False
4751+
do not attempt the longitudes or data fix for the
4752+
wrap-around.
47484753
============== ====================================================
47494754
47504755
if datain given, returns ``dataout,lonsout`` (data and longitudes shifted to fit in interval
@@ -4783,7 +4788,7 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
47834788

47844789
# if no shift necessary, itemindex will be
47854790
# empty, so don't do anything
4786-
if itemindex:
4791+
if itemindex and fix_wrap_around:
47874792
# check to see if cyclic (wraparound) point included
47884793
# if so, remove it.
47894794
if np.abs(lonsin1[0]-lonsin1[-1]) < 1.e-4:
@@ -4825,7 +4830,7 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
48254830
else:
48264831
itemindex = 0
48274832

4828-
if itemindex:
4833+
if itemindex and fix_wrap_around:
48294834
# check to see if cyclic (wraparound) point included
48304835
# if so, remove it.
48314836
if np.abs(lonsin[0]-lonsin[-1]) < 1.e-4:
@@ -4857,7 +4862,6 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
48574862
if datain is not None and mask.any():
48584863
datain = ma.masked_where(mask, datain)
48594864

4860-
48614865
if datain is not None:
48624866
return lonsin, datain
48634867
else:

0 commit comments

Comments
 (0)