Skip to content

Commit 2b4c05e

Browse files
author
Jeff Whitaker
committed
update pole-centered meridian labelling
1 parent 2824fa0 commit 2b4c05e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,9 +2164,6 @@ def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\
21642164
example labels=[1,0,0,1] will cause meridians
21652165
to be labelled where they intersect the left and
21662166
and bottom of the plot, but not the right and top.
2167-
For round pole-centered plots, if element in labels
2168-
evaluates to True, then meridians are labelled all around
2169-
the bounding latitude.
21702167
labelstyle if set to "+/-", east and west longitudes are
21712168
labelled with "+" and "-", otherwise they are
21722169
labelled with "E" and "W".
@@ -2387,7 +2384,7 @@ def addlon(meridians,madd):
23872384
for lab in labels:
23882385
if lab: label = True
23892386
for merid in meridict:
2390-
lines,labels = meridict[merid]
2387+
lines,labs = meridict[merid]
23912388
# clip lines.
23922389
for l in lines:
23932390
l.set_clip_path(self.clipcircle)
@@ -2423,6 +2420,11 @@ def addlon(meridians,madd):
24232420
vertalign = 'top'
24242421
else:
24252422
vertalign = 'center'
2423+
# labels [l,r,t,b]
2424+
if labels[0] and x >= 0.5*(self.xmin+self.xmax)+xoffset: continue
2425+
if labels[1] and x <= 0.5*(self.xmin+self.xmax)-xoffset: continue
2426+
if labels[2] and y <= 0.5*(self.ymin+self.ymax)-yoffset: continue
2427+
if labels[3] and y >= 0.5*(self.ymin+self.ymax)+yoffset: continue
24262428
elif pole == -1:
24272429
theta = (np.pi/180.)*(-merid+self.projparams['lon_0']+90)
24282430
x = r*np.cos(theta)+0.5*(self.xmin+self.xmax)
@@ -2439,6 +2441,11 @@ def addlon(meridians,madd):
24392441
vertalign = 'bottom'
24402442
else:
24412443
vertalign = 'center'
2444+
# labels [l,r,t,b]
2445+
if labels[0] and x <= 0.5*(self.xmin+self.xmax)+xoffset: continue
2446+
if labels[1] and x >= 0.5*(self.xmin+self.xmax)-xoffset: continue
2447+
if labels[2] and y >= 0.5*(self.ymin+self.ymax)-yoffset: continue
2448+
if labels[3] and y <= 0.5*(self.ymin+self.ymax)+yoffset: continue
24422449
t =\
24432450
ax.text(x,y,lonlab,horizontalalignment=horizalign,verticalalignment=vertalign,**kwargs)
24442451
meridict[merid][1].append(t)
@@ -4337,6 +4344,7 @@ def __delitem__(self,key):
43374344
super(_dict, self).__delitem__(key)
43384345

43394346
def _setlonlab(fmt,lon,labelstyle):
4347+
# set lon label string (called by Basemap.drawmeridians)
43404348
try: # fmt is a function that returns a formatted string
43414349
lonlab = fmt(lon)
43424350
except: # fmt is a format string.
@@ -4373,6 +4381,7 @@ def _setlonlab(fmt,lon,labelstyle):
43734381
return lonlab
43744382

43754383
def _setlatlab(fmt,lat,labelstyle):
4384+
# set lat label string (called by Basemap.drawparallels)
43764385
try: # fmt is a function that returns a formatted string
43774386
latlab = fmt(lat)
43784387
except: # fmt is a format string.

0 commit comments

Comments
 (0)