@@ -1668,7 +1668,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
1668
1668
limb .set_zorder (0 )
1669
1669
limb .set_edgecolor (color )
1670
1670
limb .set_linewidth (linewidth )
1671
- limb .set_clip_on (False )
1671
+ limb .set_clip_on (True )
1672
1672
if zorder is not None :
1673
1673
limb .set_zorder (zorder )
1674
1674
elif self .projection in _pseudocyl : # elliptical region.
@@ -1702,7 +1702,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
1702
1702
else :
1703
1703
limb .set_facecolor (fill_color )
1704
1704
limb .set_zorder (0 )
1705
- limb .set_clip_on (False )
1705
+ limb .set_clip_on (True )
1706
1706
if zorder is not None :
1707
1707
limb .set_zorder (zorder )
1708
1708
elif self .round :
@@ -1716,7 +1716,7 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
1716
1716
else :
1717
1717
limb .set_facecolor (fill_color )
1718
1718
limb .set_zorder (0 )
1719
- limb .set_clip_on (False )
1719
+ limb .set_clip_on (True )
1720
1720
if zorder is not None :
1721
1721
limb .set_zorder (zorder )
1722
1722
else : # all other projections are rectangular.
@@ -1834,16 +1834,17 @@ def fillcontinents(self,color='0.8',lake_color=None,ax=None,zorder=None,alpha=No
1834
1834
npoly = npoly + 1
1835
1835
# set axes limits to fit map region.
1836
1836
self .set_axes_limits (ax = ax )
1837
- # clip continent polygons for round polar plots.
1838
- if self . round : polys ,c = self ._clipcircle (ax ,polys )
1837
+ # clip continent polygons to map limbs
1838
+ polys ,c = self ._cliplimb (ax ,polys )
1839
1839
return polys
1840
1840
1841
- def _clipcircle (self ,ax ,coll ):
1842
- c = Circle ((0.5 * (self .xmax + self .xmin ),0.5 * (self .ymax + self .ymin )),
1843
- radius = 0.5 * (self .xmax - self .xmin ),fc = 'none' )
1841
+ def _cliplimb (self ,ax ,coll ):
1842
+ if not self ._mapboundarydrawn :
1843
+ return coll , None
1844
+ c = self ._mapboundarydrawn
1844
1845
if c not in ax .patches :
1845
1846
p = ax .add_patch (c )
1846
- p .set_clip_on (False )
1847
+ # p.set_clip_on(False)
1847
1848
try :
1848
1849
coll .set_clip_path (c )
1849
1850
except :
@@ -1883,11 +1884,11 @@ def drawcoastlines(self,linewidth=1.,linestyle='solid',color='k',antialiased=1,a
1883
1884
coastlines .set_label ('_nolabel_' )
1884
1885
if zorder is not None :
1885
1886
coastlines .set_zorder (zorder )
1886
- # clip coastlines for round polar plots.
1887
- if self .round : coastlines ,c = self ._clipcircle (ax ,coastlines )
1888
1887
ax .add_collection (coastlines )
1889
1888
# set axes limits to fit map region.
1890
1889
self .set_axes_limits (ax = ax )
1890
+ # clip to map limbs
1891
+ coastlines ,c = self ._cliplimb (ax ,coastlines )
1891
1892
return coastlines
1892
1893
1893
1894
def drawcountries (self ,linewidth = 0.5 ,linestyle = 'solid' ,color = 'k' ,antialiased = 1 ,ax = None ,zorder = None ):
@@ -1928,10 +1929,10 @@ def drawcountries(self,linewidth=0.5,linestyle='solid',color='k',antialiased=1,a
1928
1929
if zorder is not None :
1929
1930
countries .set_zorder (zorder )
1930
1931
ax .add_collection (countries )
1931
- # clip countries for round polar plots.
1932
- if self .round : countries ,c = self ._clipcircle (ax ,countries )
1933
1932
# set axes limits to fit map region.
1934
1933
self .set_axes_limits (ax = ax )
1934
+ # clip countries to map limbs
1935
+ countries ,c = self ._cliplimb (ax ,countries )
1935
1936
return countries
1936
1937
1937
1938
def drawstates (self ,linewidth = 0.5 ,linestyle = 'solid' ,color = 'k' ,antialiased = 1 ,ax = None ,zorder = None ):
@@ -1972,10 +1973,10 @@ def drawstates(self,linewidth=0.5,linestyle='solid',color='k',antialiased=1,ax=N
1972
1973
if zorder is not None :
1973
1974
states .set_zorder (zorder )
1974
1975
ax .add_collection (states )
1975
- # clip states for round polar plots.
1976
- if self .round : states ,c = self ._clipcircle (ax ,states )
1977
1976
# set axes limits to fit map region.
1978
1977
self .set_axes_limits (ax = ax )
1978
+ # clip states to map limbs
1979
+ states ,c = self ._cliplimb (ax ,states )
1979
1980
return states
1980
1981
1981
1982
def drawcounties (self ,linewidth = 0.1 ,linestyle = 'solid' ,color = 'k' ,antialiased = 1 ,
@@ -2058,10 +2059,10 @@ def drawrivers(self,linewidth=0.5,linestyle='solid',color='k',antialiased=1,ax=N
2058
2059
if zorder is not None :
2059
2060
rivers .set_zorder (zorder )
2060
2061
ax .add_collection (rivers )
2061
- # clip rivers for round polar plots.
2062
- if self .round : rivers ,c = self ._clipcircle (ax ,rivers )
2063
2062
# set axes limits to fit map region.
2064
2063
self .set_axes_limits (ax = ax )
2064
+ # clip rivers to map limbs
2065
+ rivers ,c = self ._cliplimb (ax ,rivers )
2065
2066
return rivers
2066
2067
2067
2068
def is_land (self ,xpt ,ypt ):
@@ -2229,10 +2230,10 @@ def readshapefile(self,shapefile,name,drawbounds=True,zorder=None,
2229
2230
if zorder is not None :
2230
2231
lines .set_zorder (zorder )
2231
2232
ax .add_collection (lines )
2232
- # clip boundaries for round polar plots.
2233
- if self .round : lines ,c = self ._clipcircle (ax ,lines )
2234
2233
# set axes limits to fit map region.
2235
2234
self .set_axes_limits (ax = ax )
2235
+ # clip boundaries to map limbs
2236
+ lines ,c = self ._cliplimb (ax ,lines )
2236
2237
info = info + (lines ,)
2237
2238
self .__dict__ [name ]= coords
2238
2239
self .__dict__ [name + '_info' ]= attributes
@@ -2512,16 +2513,8 @@ def drawparallels(self,circles,color='k',textcolor='k',linewidth=1.,zorder=None,
2512
2513
# override __delitem__ in dict to call remove() on values.
2513
2514
pardict = _dict (linecolls )
2514
2515
# clip parallels for round polar plots (and delete labels).
2515
- if self .round :
2516
- c = Circle ((0.5 * (self .xmax + self .xmin ),0.5 * (self .ymax + self .ymin )),
2517
- radius = 0.5 * (self .xmax - self .xmin ),fc = 'none' )
2518
- if c not in ax .patches :
2519
- p = ax .add_patch (c )
2520
- p .set_clip_on (False )
2521
- for par in pardict :
2522
- lines ,labs = pardict [par ]
2523
- for l in lines :
2524
- l .set_clip_path (c )
2516
+ for lines , _ in pardict .values ():
2517
+ self ._cliplimb (ax , lines )
2525
2518
return pardict
2526
2519
2527
2520
def drawmeridians (self ,meridians ,color = 'k' ,textcolor = 'k' ,linewidth = 1. , zorder = None ,\
@@ -2766,20 +2759,11 @@ def addlon(meridians,madd):
2766
2759
meridict = _dict (linecolls )
2767
2760
# for round polar plots, clip meridian lines and label them.
2768
2761
if self .round :
2769
- c = Circle ((0.5 * (self .xmax + self .xmin ),0.5 * (self .ymax + self .ymin )),
2770
- radius = 0.5 * (self .xmax - self .xmin ),fc = 'none' )
2771
- if c not in ax .patches :
2772
- p = ax .add_patch (c )
2773
- p .set_clip_on (False )
2774
2762
# label desired?
2775
2763
label = False
2776
2764
for lab in labels :
2777
2765
if lab : label = True
2778
2766
for merid in meridict :
2779
- lines ,labs = meridict [merid ]
2780
- # clip lines.
2781
- for l in lines :
2782
- l .set_clip_path (c )
2783
2767
if not label : continue
2784
2768
# label
2785
2769
lonlab = _setlonlab (fmt ,merid ,labelstyle )
@@ -2840,6 +2824,8 @@ def addlon(meridians,madd):
2840
2824
if labels [3 ] and not labels [2 ] and y <= 0.5 * (self .ymin + self .ymax )+ yoffset : continue
2841
2825
t = ax .text (x ,y ,lonlab ,horizontalalignment = horizalign ,verticalalignment = vertalign ,** text_kwargs )
2842
2826
meridict [merid ][1 ].append (t )
2827
+ for lines , _ in meridict .values ():
2828
+ self ._cliplimb (ax , lines )
2843
2829
return meridict
2844
2830
2845
2831
def tissot (self ,lon_0 ,lat_0 ,radius_deg ,npts ,ax = None ,** kwargs ):
@@ -2877,10 +2863,10 @@ def tissot(self,lon_0,lat_0,radius_deg,npts,ax=None,**kwargs):
2877
2863
seg .append ((x ,y ))
2878
2864
poly = Polygon (seg ,** kwargs )
2879
2865
ax .add_patch (poly )
2880
- # clip polygons for round polar plots.
2881
- if self .round : poly ,c = self ._clipcircle (ax ,poly )
2882
2866
# set axes limits to fit map region.
2883
2867
self .set_axes_limits (ax = ax )
2868
+ # clip polygons to map limbs
2869
+ poly ,c = self ._cliplimb (ax ,poly )
2884
2870
return poly
2885
2871
2886
2872
def gcpoints (self ,lon1 ,lat1 ,lon2 ,lat2 ,npoints ):
@@ -3291,10 +3277,10 @@ def scatter(self, *args, **kwargs):
3291
3277
# reset current active image (only if pyplot is imported).
3292
3278
if plt :
3293
3279
plt .sci (ret )
3294
- # clip for round polar plots.
3295
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3296
3280
# set axes limits to fit map region.
3297
3281
self .set_axes_limits (ax = ax )
3282
+ # clip to map limbs
3283
+ ret ,c = self ._cliplimb (ax ,ret )
3298
3284
return ret
3299
3285
3300
3286
@_transform1d
@@ -3326,10 +3312,10 @@ def plot(self, *args, **kwargs):
3326
3312
ax .hold (b )
3327
3313
raise
3328
3314
ax .hold (b )
3329
- # clip for round polar plots.
3330
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3331
3315
# set axes limits to fit map region.
3332
3316
self .set_axes_limits (ax = ax )
3317
+ # clip to map limbs
3318
+ ret ,c = self ._cliplimb (ax ,ret )
3333
3319
return ret
3334
3320
3335
3321
def imshow (self , * args , ** kwargs ):
@@ -3365,10 +3351,10 @@ def imshow(self, *args, **kwargs):
3365
3351
# reset current active image (only if pyplot is imported).
3366
3352
if plt :
3367
3353
plt .sci (ret )
3368
- # clip image for round polar plots.
3369
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3370
3354
# set axes limits to fit map region.
3371
3355
self .set_axes_limits (ax = ax )
3356
+ # clip image to map limbs
3357
+ ret ,c = self ._cliplimb (ax ,ret )
3372
3358
return ret
3373
3359
3374
3360
@_transform
@@ -3445,10 +3431,10 @@ def pcolor(self,x,y,data,**kwargs):
3445
3431
# reset current active image (only if pyplot is imported).
3446
3432
if plt :
3447
3433
plt .sci (ret )
3448
- # clip for round polar plots.
3449
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3450
3434
# set axes limits to fit map region.
3451
3435
self .set_axes_limits (ax = ax )
3436
+ # clip to map limbs
3437
+ ret ,c = self ._cliplimb (ax ,ret )
3452
3438
if self .round :
3453
3439
# for some reason, frame gets turned on.
3454
3440
ax .set_frame_on (False )
@@ -3490,10 +3476,10 @@ def pcolormesh(self,x,y,data,**kwargs):
3490
3476
# reset current active image (only if pyplot is imported).
3491
3477
if plt :
3492
3478
plt .sci (ret )
3493
- # clip for round polar plots.
3494
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3495
3479
# set axes limits to fit map region.
3496
3480
self .set_axes_limits (ax = ax )
3481
+ # clip to map limbs
3482
+ ret ,c = self ._cliplimb (ax ,ret )
3497
3483
if self .round :
3498
3484
# for some reason, frame gets turned on.
3499
3485
ax .set_frame_on (False )
@@ -3540,10 +3526,10 @@ def hexbin(self,x,y,**kwargs):
3540
3526
# reset current active image (only if pyplot is imported).
3541
3527
if plt :
3542
3528
plt .sci (ret )
3543
- # clip for round polar plots.
3544
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3545
3529
# set axes limits to fit map region.
3546
3530
self .set_axes_limits (ax = ax )
3531
+ # clip to map limbs
3532
+ ret ,c = self ._cliplimb (ax ,ret )
3547
3533
return ret
3548
3534
3549
3535
@_transform
@@ -3640,10 +3626,10 @@ def contour(self,x,y,data,*args,**kwargs):
3640
3626
# reset current active image (only if pyplot is imported).
3641
3627
if plt and CS .get_array () is not None :
3642
3628
plt .sci (CS )
3643
- # clip for round polar plots.
3644
- if self .round : CS .collections ,c = self ._clipcircle (ax ,CS .collections )
3645
3629
# set axes limits to fit map region.
3646
3630
self .set_axes_limits (ax = ax )
3631
+ # clip to map limbs
3632
+ CS .collections ,c = self ._cliplimb (ax ,CS .collections )
3647
3633
return CS
3648
3634
3649
3635
@_transform
@@ -3747,8 +3733,8 @@ def contourf(self,x,y,data,*args,**kwargs):
3747
3733
plt .sci (CS )
3748
3734
# set axes limits to fit map region.
3749
3735
self .set_axes_limits (ax = ax )
3750
- # clip for round polar plots.
3751
- if self . round : CS .collections ,c = self ._clipcircle (ax ,CS .collections )
3736
+ # clip to map limbs
3737
+ CS .collections ,c = self ._cliplimb (ax ,CS .collections )
3752
3738
return CS
3753
3739
3754
3740
@_transformuv
@@ -3783,10 +3769,10 @@ def quiver(self, x, y, u, v, *args, **kwargs):
3783
3769
ax .hold (b )
3784
3770
if plt is not None and ret .get_array () is not None :
3785
3771
plt .sci (ret )
3786
- # clip for round polar plots.
3787
- if self .round : ret ,c = self ._clipcircle (ax ,ret )
3788
3772
# set axes limits to fit map region.
3789
3773
self .set_axes_limits (ax = ax )
3774
+ # clip to map limbs
3775
+ ret ,c = self ._cliplimb (ax ,ret )
3790
3776
return ret
3791
3777
3792
3778
@_transformuv
@@ -3825,15 +3811,15 @@ def streamplot(self, x, y, u, v, *args, **kwargs):
3825
3811
ax .hold (b )
3826
3812
if plt is not None and ret .lines .get_array () is not None :
3827
3813
plt .sci (ret .lines )
3828
- # clip for round polar plots.
3814
+ # set axes limits to fit map region.
3815
+ self .set_axes_limits (ax = ax )
3816
+ # clip to map limbs
3817
+ ret ,c = self ._cliplimb (ax ,ret )
3829
3818
# streamplot arrows not returned in matplotlib 1.1.1, so clip all
3830
3819
# FancyArrow patches attached to axes instance.
3831
- if self . round :
3832
- ret ,c = self ._clipcircle (ax ,ret )
3820
+ if c is not None :
3833
3821
for p in ax .patches :
3834
3822
if isinstance (p ,FancyArrowPatch ): p .set_clip_path (c )
3835
- # set axes limits to fit map region.
3836
- self .set_axes_limits (ax = ax )
3837
3823
return ret
3838
3824
3839
3825
@_transformuv
@@ -3884,12 +3870,12 @@ def barbs(self, x, y, u, v, *args, **kwargs):
3884
3870
# we can't set the current image...
3885
3871
#if plt is not None and ret.get_array() is not None:
3886
3872
# plt.sci(retnh)
3887
- # clip for round polar plots.
3888
- if self .round :
3889
- retnh ,c = self ._clipcircle (ax ,retnh )
3890
- retsh ,c = self ._clipcircle (ax ,retsh )
3891
3873
# set axes limits to fit map region.
3892
3874
self .set_axes_limits (ax = ax )
3875
+ # clip to map limbs
3876
+ retnh ,c = self ._cliplimb (ax ,retnh )
3877
+ retsh ,c = self ._cliplimb (ax ,retsh )
3878
+
3893
3879
return retnh ,retsh
3894
3880
3895
3881
def drawlsmask (self ,land_color = "0.8" ,ocean_color = "w" ,lsmask = None ,
@@ -4031,8 +4017,8 @@ def drawlsmask(self,land_color="0.8",ocean_color="w",lsmask=None,
4031
4017
rgba [:,:,3 ] = np .where (self .lsmask == 255 ,0 ,rgba [:,:,3 ])
4032
4018
# plot mask as rgba image.
4033
4019
im = self .imshow (rgba ,interpolation = 'nearest' ,ax = ax ,** kwargs )
4034
- # clip for round polar plots .
4035
- if self . round : im ,c = self ._clipcircle (ax ,im )
4020
+ # clip to map limbs .
4021
+ im ,c = self ._cliplimb (ax ,im )
4036
4022
return im
4037
4023
4038
4024
def bluemarble (self ,ax = None ,scale = None ,** kwargs ):
@@ -4253,20 +4239,22 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
4253
4239
self ._bm_rgba_warped = \
4254
4240
ma .masked_array (self ._bm_rgba_warped ,mask = mask )
4255
4241
# make points outside projection limb transparent.
4242
+ # FIXME: Probably not needed anymore
4256
4243
self ._bm_rgba_warped = self ._bm_rgba_warped .filled (0. )
4257
4244
# plot warped rgba image.
4258
4245
im = self .imshow (self ._bm_rgba_warped ,ax = ax ,** kwargs )
4259
4246
# for hammer projection, use clip path defined by
4260
4247
# projection limb (patch created in drawmapboundary).
4248
+ # FIXME: Is this now redundant?
4261
4249
if self .projection == 'hammer' :
4262
4250
if not self ._mapboundarydrawn :
4263
4251
self .drawmapboundary (color = 'none' ,linewidth = None )
4264
4252
im .set_clip_path (self ._mapboundarydrawn )
4265
4253
else :
4266
4254
# bmproj True, no interpolation necessary.
4267
4255
im = self .imshow (self ._bm_rgba ,ax = ax ,** kwargs )
4268
- # clip for round polar plots.
4269
- if self . round : im ,c = self ._clipcircle (ax ,im )
4256
+ # clip to map limbs
4257
+ im ,c = self ._cliplimb (ax ,im )
4270
4258
return im
4271
4259
4272
4260
def arcgisimage (self ,server = 'http://server.arcgisonline.com/ArcGIS' ,\
@@ -4715,8 +4703,8 @@ def nightshade(self,date,color="k",delta=0.25,alpha=0.5,ax=None,zorder=2):
4715
4703
# is on top.
4716
4704
for c in CS .collections :
4717
4705
c .set_zorder (zorder )
4718
- # clip for round polar plots.
4719
- if self . round : CS .collections ,c = self ._clipcircle (ax ,CS .collections )
4706
+ # clip to map limbs
4707
+ CS .collections ,c = self ._cliplimb (ax ,CS .collections )
4720
4708
return CS
4721
4709
4722
4710
def _check_ax (self ):
0 commit comments