@@ -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.
@@ -4723,7 +4724,7 @@ def _ax_plt_from_kw(self, kw):
4723
4724
_ax = plt .gca ()
4724
4725
return _ax , plt
4725
4726
4726
- def shiftdata (self ,lonsin ,datain = None ,lon_0 = None ):
4727
+ def shiftdata (self ,lonsin ,datain = None ,lon_0 = None , fix_wrap_around = True ):
4727
4728
"""
4728
4729
Shift longitudes (and optionally data) so that they match map projection region.
4729
4730
Only valid for cylindrical/pseudo-cylindrical global projections and data
@@ -4746,6 +4747,10 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
4746
4747
datain original 1-d or 2-d data. Default None.
4747
4748
lon_0 center of map projection region. Defaut None,
4748
4749
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.
4749
4754
============== ====================================================
4750
4755
4751
4756
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):
4784
4789
4785
4790
# if no shift necessary, itemindex will be
4786
4791
# empty, so don't do anything
4787
- if itemindex :
4792
+ if itemindex and fix_wrap_around :
4788
4793
# check to see if cyclic (wraparound) point included
4789
4794
# if so, remove it.
4790
4795
if np .abs (lonsin1 [0 ]- lonsin1 [- 1 ]) < 1.e-4 :
@@ -4826,7 +4831,7 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
4826
4831
else :
4827
4832
itemindex = 0
4828
4833
4829
- if itemindex :
4834
+ if itemindex and fix_wrap_around :
4830
4835
# check to see if cyclic (wraparound) point included
4831
4836
# if so, remove it.
4832
4837
if np .abs (lonsin [0 ]- lonsin [- 1 ]) < 1.e-4 :
@@ -4858,7 +4863,6 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
4858
4863
if datain is not None and mask .any ():
4859
4864
datain = ma .masked_where (mask , datain )
4860
4865
4861
-
4862
4866
if datain is not None :
4863
4867
return lonsin , datain
4864
4868
else :
0 commit comments