Skip to content

Commit 7f7fa8c

Browse files
author
Jeff Whitaker
committed
add wraparound capability to drawmeridians.
1 parent 8188255 commit 7f7fa8c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
since version 1.0.2
22
* fix typo in setup.py (replace "!= ['sdist','clean']" with
33
"not in ['sdist','clean']").
4+
* make sure drawmeridians can handle wrap-around (so that
5+
if projection is defined in -180 to 0 and user asks for
6+
meridians from 180 to 360 to be drawn, it should work).
7+
Only affects projections 'mill','gall','merc' and 'cyl'.
8+
49
version 1.0.2 (git tag v1.0.2)
510
* update include geos from 3.2.0 to 3.3.1 so it compiles with gcc
611
4.6.

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,21 @@ def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\
21322132
associated with each meridian. Deleting an item from the
21332133
dictionary removes the correpsonding meridian from the plot.
21342134
"""
2135+
# for cylindrical projections, try to handle wraparound (i.e. if
2136+
# projection is defined in -180 to 0 and user asks for meridians from
2137+
# 180 to 360 to be drawn, it should work)
2138+
if self.projection in _cylproj:
2139+
def addlon(meridians,madd):
2140+
minside = (madd >= self.llcrnrlon and madd <= self.urcrnrlon)
2141+
if minside and madd not in meridians: meridians.append(madd)
2142+
return meridians
2143+
merids = list(meridians)
2144+
meridians = []
2145+
for m in merids:
2146+
meridians = addlon(meridians,m)
2147+
meridians = addlon(meridians,m+360)
2148+
meridians = addlon(meridians,m-360)
2149+
meridians.sort()
21352150
# if celestial=True, don't use "E" and "W" labels.
21362151
if labelstyle is None and self.celestial:
21372152
labelstyle="+/-"

0 commit comments

Comments
 (0)