@@ -526,7 +526,8 @@ def with_transform(self,x,y,data,*args,**kwargs):
526
526
# shift data to map projection region for
527
527
# cylindrical and pseudo-cylindrical projections.
528
528
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" ])
530
531
# convert lat/lon coords to map projection coords.
531
532
x , y = self (x ,y )
532
533
return plotfunc (self ,x ,y ,data ,* args ,** kwargs )
@@ -544,7 +545,7 @@ def with_transform(self,x,y,*args,**kwargs):
544
545
# cylindrical and pseudo-cylindrical projections.
545
546
if self .projection in _cylproj or self .projection in _pseudocyl :
546
547
if x .ndim == 1 :
547
- x = self .shiftdata (x )
548
+ x = self .shiftdata (x , fix_wrap_around = plotfunc . __name__ not in [ "scatter" ] )
548
549
elif x .ndim == 0 :
549
550
if x > 180 :
550
551
x = x - 360.
@@ -4722,7 +4723,7 @@ def _ax_plt_from_kw(self, kw):
4722
4723
_ax = plt .gca ()
4723
4724
return _ax , plt
4724
4725
4725
- def shiftdata (self ,lonsin ,datain = None ,lon_0 = None ):
4726
+ def shiftdata (self ,lonsin ,datain = None ,lon_0 = None , fix_wrap_around = True ):
4726
4727
"""
4727
4728
Shift longitudes (and optionally data) so that they match map projection region.
4728
4729
Only valid for cylindrical/pseudo-cylindrical global projections and data
@@ -4745,6 +4746,10 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
4745
4746
datain original 1-d or 2-d data. Default None.
4746
4747
lon_0 center of map projection region. Defaut None,
4747
4748
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.
4748
4753
============== ====================================================
4749
4754
4750
4755
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):
4783
4788
4784
4789
# if no shift necessary, itemindex will be
4785
4790
# empty, so don't do anything
4786
- if itemindex :
4791
+ if itemindex and fix_wrap_around :
4787
4792
# check to see if cyclic (wraparound) point included
4788
4793
# if so, remove it.
4789
4794
if np .abs (lonsin1 [0 ]- lonsin1 [- 1 ]) < 1.e-4 :
@@ -4825,7 +4830,7 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
4825
4830
else :
4826
4831
itemindex = 0
4827
4832
4828
- if itemindex :
4833
+ if itemindex and fix_wrap_around :
4829
4834
# check to see if cyclic (wraparound) point included
4830
4835
# if so, remove it.
4831
4836
if np .abs (lonsin [0 ]- lonsin [- 1 ]) < 1.e-4 :
@@ -4857,7 +4862,6 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
4857
4862
if datain is not None and mask .any ():
4858
4863
datain = ma .masked_where (mask , datain )
4859
4864
4860
-
4861
4865
if datain is not None :
4862
4866
return lonsin , datain
4863
4867
else :
0 commit comments