@@ -4258,6 +4258,7 @@ def arcgisimage(self,server='http://server.arcgisonline.com/ArcGIS',\
4258
4258
Basemap instance must be creating using an EPSG code
4259
4259
(http://spatialreference.org) in order to use the wmsmap method""" )
4260
4260
raise ValueError (msg )
4261
+ ax = kwargs .pop ('ax' , None ) or self ._check_ax ()
4261
4262
# find the x,y values at the corner points.
4262
4263
p = pyproj .Proj (init = "epsg:%s" % self .epsg , preserve_units = True )
4263
4264
xmin ,ymin = p (self .llcrnrlon ,self .llcrnrlat )
@@ -4291,7 +4292,8 @@ def arcgisimage(self,server='http://server.arcgisonline.com/ArcGIS',\
4291
4292
# print URL?
4292
4293
if verbose : print basemap_url
4293
4294
# 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' )
4295
4297
4296
4298
def wmsimage (self ,server ,\
4297
4299
xpixels = 400 ,ypixels = None ,\
@@ -4336,6 +4338,7 @@ def wmsimage(self,server,\
4336
4338
except ImportError :
4337
4339
raise ImportError ('OWSLib required to use wmsimage method' )
4338
4340
import urllib2 , io
4341
+ ax = kwargs .pop ('ax' , None ) or self ._check_ax ()
4339
4342
if not hasattr (self ,'epsg' ):
4340
4343
msg = dedent ("""
4341
4344
Basemap instance must be creating using an EPSG code
@@ -4382,7 +4385,7 @@ def wmsimage(self,server,\
4382
4385
# return AxesImage instance.
4383
4386
# this works for png and jpeg.
4384
4387
return self .imshow (imread (io .BytesIO (img .read ()),
4385
- format = format ),origin = 'upper' ,alpha = alpha )
4388
+ format = format ),origin = 'upper' ,alpha = alpha , ax = ax )
4386
4389
# this works for png, but not jpeg
4387
4390
#return self.imshow(imread(urllib2.urlopen(img.url),format=format),origin='upper')
4388
4391
@@ -4653,7 +4656,9 @@ def nightshade(self,date,color="k",delta=0.25,alpha=0.5,ax=None,zorder=2):
4653
4656
from .solar import daynight_grid
4654
4657
# make sure date is UTC, or naive with repect to time zones
4655
4658
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 ()
4657
4662
# create grid of day=0, night=1
4658
4663
lons ,lats ,daynight = daynight_grid (date ,delta ,self .lonmin ,self .lonmax )
4659
4664
x ,y = self (lons ,lats )
0 commit comments