Skip to content

Commit a777789

Browse files
committed
do not try to fix wrap-around for scatter
1 parent 928421d commit a777789

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.
@@ -4723,7 +4724,7 @@ def _ax_plt_from_kw(self, kw):
47234724
_ax = plt.gca()
47244725
return _ax, plt
47254726

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

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

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

4861-
48624866
if datain is not None:
48634867
return lonsin, datain
48644868
else:

0 commit comments

Comments
 (0)