Skip to content

Commit 66115db

Browse files
authored
Merge pull request #310 from WeatherGod/fix_missing_ax
Add missing ax checking
2 parents a6926ae + 9ce521f commit 66115db

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4258,6 +4258,7 @@ def arcgisimage(self,server='http://server.arcgisonline.com/ArcGIS',\
42584258
Basemap instance must be creating using an EPSG code
42594259
(http://spatialreference.org) in order to use the wmsmap method""")
42604260
raise ValueError(msg)
4261+
ax = kwargs.pop('ax', None) or self._check_ax()
42614262
# find the x,y values at the corner points.
42624263
p = pyproj.Proj(init="epsg:%s" % self.epsg, preserve_units=True)
42634264
xmin,ymin = p(self.llcrnrlon,self.llcrnrlat)
@@ -4291,7 +4292,8 @@ def arcgisimage(self,server='http://server.arcgisonline.com/ArcGIS',\
42914292
# print URL?
42924293
if verbose: print basemap_url
42934294
# return AxesImage instance.
4294-
return self.imshow(imread(urllib2.urlopen(basemap_url)),origin='upper')
4295+
return self.imshow(imread(urllib2.urlopen(basemap_url)),ax=ax,
4296+
origin='upper')
42954297

42964298
def wmsimage(self,server,\
42974299
xpixels=400,ypixels=None,\
@@ -4336,6 +4338,7 @@ def wmsimage(self,server,\
43364338
except ImportError:
43374339
raise ImportError('OWSLib required to use wmsimage method')
43384340
import urllib2, io
4341+
ax = kwargs.pop('ax', None) or self._check_ax()
43394342
if not hasattr(self,'epsg'):
43404343
msg = dedent("""
43414344
Basemap instance must be creating using an EPSG code
@@ -4382,7 +4385,7 @@ def wmsimage(self,server,\
43824385
# return AxesImage instance.
43834386
# this works for png and jpeg.
43844387
return self.imshow(imread(io.BytesIO(img.read()),
4385-
format=format),origin='upper',alpha=alpha)
4388+
format=format),origin='upper',alpha=alpha,ax=ax)
43864389
# this works for png, but not jpeg
43874390
#return self.imshow(imread(urllib2.urlopen(img.url),format=format),origin='upper')
43884391

@@ -4653,7 +4656,9 @@ def nightshade(self,date,color="k",delta=0.25,alpha=0.5,ax=None,zorder=2):
46534656
from .solar import daynight_grid
46544657
# make sure date is UTC, or naive with repect to time zones
46554658
if date.utcoffset():
4656-
raise ValueError('datetime instance must be UTC, not {}'.format(date.tzname()))
4659+
raise ValueError('datetime instance must be UTC, not {0}'.format(date.tzname()))
4660+
# get current axes instance (if none specified).
4661+
ax = ax or self._check_ax()
46574662
# create grid of day=0, night=1
46584663
lons,lats,daynight = daynight_grid(date,delta,self.lonmin,self.lonmax)
46594664
x,y = self(lons,lats)

0 commit comments

Comments
 (0)