Skip to content

Commit 072ba45

Browse files
author
Jeff Whitaker
committed
more fixes for meridian labelling for round polar plots.
1 parent 2b4c05e commit 072ba45

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

examples/polarmaps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# showing all four polar projections.
2727
for hem in ['North','South']:
2828
if hem == 'South':
29-
lon_0 = -130.
29+
lon_0 = 130.
3030
lon_0_ortho = lon_0 - 180.
3131
lat_0 = -90.
3232
# Lambert Azimuth bounding lat must not extend into opposite hem.
@@ -63,7 +63,8 @@
6363
m.drawcoastlines()
6464
# draw parallels and meridians.
6565
m.drawparallels(np.arange(-80.,90,20.))
66-
m.drawmeridians(np.arange(0.,340.,30.),labels=[1,0,0,0],fontsize=7)
66+
#labels = [l,r,t,b]
67+
m.drawmeridians(np.arange(0.,340.,30.),labels=[1,1,1,1],fontsize=7)
6768
# draw boundary around map region.
6869
m.drawmapboundary()
6970
# draw title.

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,9 +2402,9 @@ def addlon(meridians,madd):
24022402
elif self.projection == 'ortho' and self.round:
24032403
pole = 1
24042404
if pole == 1:
2405-
if self.projection != 'ortho':
2406-
theta = (np.pi/180.)*(merid-self.projparams['lon_0']-90)
2407-
else:
2405+
theta = (np.pi/180.)*(merid-self.projparams['lon_0']-90)
2406+
if self.projection == 'ortho' and\
2407+
self.projparams['lat_0'] == -90:
24082408
theta = (np.pi/180.)*(-merid+self.projparams['lon_0']+90)
24092409
x = r*np.cos(theta)+0.5*(self.xmin+self.xmax)
24102410
y = r*np.sin(theta)+0.5*(self.ymin+self.ymax)
@@ -2421,10 +2421,10 @@ def addlon(meridians,madd):
24212421
else:
24222422
vertalign = 'center'
24232423
# 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
2424+
if labels[0] and not labels[1] and x >= 0.5*(self.xmin+self.xmax)+xoffset: continue
2425+
if labels[1] and not labels[0] and x <= 0.5*(self.xmin+self.xmax)-xoffset: continue
2426+
if labels[2] and not labels[3] and y <= 0.5*(self.ymin+self.ymax)-yoffset: continue
2427+
if labels[3] and not labels[2]and y >= 0.5*(self.ymin+self.ymax)+yoffset: continue
24282428
elif pole == -1:
24292429
theta = (np.pi/180.)*(-merid+self.projparams['lon_0']+90)
24302430
x = r*np.cos(theta)+0.5*(self.xmin+self.xmax)
@@ -2442,10 +2442,10 @@ def addlon(meridians,madd):
24422442
else:
24432443
vertalign = 'center'
24442444
# 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
2445+
if labels[0] and not labels[1] and x <= 0.5*(self.xmin+self.xmax)+xoffset: continue
2446+
if labels[1] and not labels[0] and x >= 0.5*(self.xmin+self.xmax)-xoffset: continue
2447+
if labels[2] and not labels[3] and y >= 0.5*(self.ymin+self.ymax)-yoffset: continue
2448+
if labels[3] and not labels[2] and y <= 0.5*(self.ymin+self.ymax)+yoffset: continue
24492449
t =\
24502450
ax.text(x,y,lonlab,horizontalalignment=horizalign,verticalalignment=vertalign,**kwargs)
24512451
meridict[merid][1].append(t)

0 commit comments

Comments
 (0)