本文整理汇总了Python中mpl_toolkits.basemap.Basemap.drawcounties方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.drawcounties方法的具体用法?Python Basemap.drawcounties怎么用?Python Basemap.drawcounties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.drawcounties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_locations
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def plot_locations(result,amenity,top):
import pandas as pd
import numpy
lat = []
lon = []
for res in result:
lat.append(res['pos'][0])
lon.append(res['pos'][1])
geo = pd.DataFrame(lat, columns = ['lat'])
geo['lon'] = lon
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
my_map = Basemap(projection='merc', lat_0=geo.median()[0], lon_0=geo.median()[1],
resolution = 'h', area_thresh = .1,
llcrnrlon=geo.min()[1]-.1, llcrnrlat=geo.min()[0]-.1,
urcrnrlon=geo.max()[1]+.1, urcrnrlat=geo.max()[0]+.1)
my_map.drawrivers()
my_map.drawcounties()
my_map.fillcontinents(color='tan')
my_map.drawmapboundary()
my_map.drawcoastlines()
x,y = my_map(lon, lat)
my_map.plot(x,y, 'bo', markersize=2)
title = 'Map Showing %s Added by \"%s\"\nThe Top %s Editor' % (str(amenity).title(),str(top),str(amenity).title())
plt.title(title)
p = plt.show()
return p
示例2: show_route
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def show_route(self):
'''
Display the route coordinates on a map of Tompkins County
'''
# plot basemap w/ state and county lines, etc
fig = plt.figure()
m = Basemap(llcrnrlon=-76.8, llcrnrlat=42.2, urcrnrlon=-76.2, \
urcrnrlat=42.7, rsphere=(6378137.00,6356752.3142), resolution='l', \
projection='merc')
m.shadedrelief()
m.drawcoastlines()
m.drawstates()
m.drawcountries()
m.drawcounties()
# plot ny state water features
m.readshapefile('data\\water\\NHD_M_36_New_York_ST\\NHDFlowline','water', color='LightSteelBlue', linewidth=2.)
m.readshapefile('data\\water\\NHD_M_36_New_York_ST\\NHDArea','water_area', drawbounds=False)
m.readshapefile('data\\water\\NHD_M_36_New_York_ST\\NHDWaterbody','lakes', drawbounds=False)
for lake in m.lakes + m.water_area:
poly = Polygon(lake, facecolor='LightSteelBlue', edgecolor='CornflowerBlue')
plt.gca().add_patch(poly)
# read and plot tompkins county shapefile
m.readshapefile('data\\parcels\\ParcelPublic2016_WGS84', 'parcels')
# plot route coordinates
m.plot(self.coordinates[:,0], self.coordinates[:,1], '.-',
latlon=True, c='FireBrick', lw=2.)
# finalize and show plot
fig.show()
示例3: make_NYC_basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def make_NYC_basemap(self, ax=None, lllat=40.45, urlat=40.95, lllon=-74.3, urlon=-73.68):
'''
This function creates the initial NYC basemap. It is only called once (in the initialization
of an NYC_school_interactive_map instance), since it has a relatively long run-time (it queries
the ESRI REST server to get a relatively high-resolution basemap image).
'''
fig = plt.figure(figsize=(12,12))
ax = plt.subplot(111)
m = Basemap(ax = ax,
lon_0=(urlon + lllon)/2,
lat_0=(urlat + lllat)/2,
llcrnrlat=lllat, urcrnrlat=urlat,
llcrnrlon=lllon, urcrnrlon=urlon,
resolution='f', epsg=3857) ###epsg is the projection code for ESRI world shaded relief basemap
#m.arcgisimage queries the ESRI REST API (server below) to get the basemap
#http://server.arcgisonline.com/arcgis/rest/services
m.arcgisimage(service='World_Shaded_Relief', xpixels = 1500)
# Add county lines, since boroughs map onto counties
m.drawcounties(linewidth=0.5)
return m, ax, fig
示例4: plot_nc
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def plot_nc(lons, lats, precips):
m = Basemap(width=200000, height=200000, projection='stere',
lat_0=lat_0, lon_0=lon_0)
lon, lat = np.meshgrid(lons, lats)
xi, yi = m(lon, lat)
cs = m.pcolor(xi, yi, precips[0])
m.drawstates()
m.drawcounties()
cbar = m.colorbar(cs, location='bottom', pad='10%')
plt.show()
示例5: CO2nWind
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def CO2nWind(file,outputdir):
"""
Outputs plots of CO2 in the lowest level and 10m winds
"""
import matplotlib
matplotlib.use('Agg')
import numpy as np
import sys
from netCDF4 import Dataset
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
# read in file and vars
f = Dataset(file,'r')
wrfeta = f.variables['ZNU'][0][:]
times = f.variables['Times'][:]
wrflats = f.variables['XLAT'][0][:]
wrflons = f.variables['XLONG'][0][:]
var = f.variables['CO2_ANT'][:,0,:,:]
u = f.variables['U'][:,0,:,:]
v = f.variables['V'][:,0,:,:]
# destagger u/v
u = (u[:,:,:-1] + u[:,:,1:])/2.
v = (v[:,:-1,:] + v[:,1:,:])/2.
# four corners of domain
wrflat_s = wrflats[0,len(wrflats)-1]
wrflat_n = wrflats[len(wrflats)-1,len(wrflons[0])-1]
wrflon_w = wrflons[0,0]
wrflon_e = wrflons[len(wrflats)-1,len(wrflons[0])-1]
z = 0 # assuming lowest level of model
# set up map
map = Basemap(projection='merc',llcrnrlon=wrflon_w,urcrnrlon=wrflon_e,llcrnrlat=wrflat_s,urcrnrlat=wrflat_n,resolution='i')
map.drawstates()
map.drawcounties()
map.drawcoastlines()
x,y = map(wrflons,wrflats)
# loop through times
for t in range(len(times)):
timestr = ''.join(times[t,:])
map.drawstates(color='gray',linewidth=1)
map.drawcounties(color='white')
map.drawcoastlines(color='gray',linewidth=1)
plt1 = map.pcolormesh(x,y,var[t,:,:],vmin=380,vmax=450)
#plt1 = map.pcolormesh(x,y,var[t,:,:],vmin=np.amin(var),vmax=np.amax(var))
winds = map.barbs(x[::20,::20],y[::20,::20],u[t,::20,::20]*1.94,v[t,::20,::20]*1.94,length=6,color='white') # *1.94 to convert m/s to knots (barb convention)
colorbar = map.colorbar(plt1,"right", size="5%",pad="2%")
colorbar.set_label(f.variables['CO2_ANT'].description+' '+f.variables['CO2_ANT'].units)
plt.title('WRF output valid: '+timestr)
plt.savefig(outputdir+'/%03d_' % (t) +timestr+'_CO2_wind.png')
plt.clf()
示例6: _basemap_district
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def _basemap_district(min_lat, min_lon, max_lat, max_lon):
""" This function creates a Basemap instance that is a map of a District of chicago
:param min_lat, min_lon, max_lat, max_lon: integers or floats representing vertices of the map
:return district_map
"""
district_map = Basemap(llcrnrlon=min_lon, llcrnrlat=min_lat, urcrnrlon=max_lon, urcrnrlat=max_lat, projection="merc", resolution = 'h')
district_map.drawcoastlines()
district_map.drawcountries()
district_map.drawcounties()
district_map.drawmapboundary()
district_map.drawrivers(color='#0000ff')
return district_map
示例7: basicsurfmap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def basicsurfmap(file,varstr,outputdir):
"""
Creates plots for each timestep of a file
for the specified variable and outputs them
to a specified directory
"""
import matplotlib
matplotlib.use('Agg')
import numpy as np
import sys
from netCDF4 import Dataset
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
# read in file and vars
f = Dataset(file,'r')
wrfeta = f.variables['ZNU'][0][:]
times = f.variables['Times'][:]
wrflats = f.variables['XLAT'][0][:]
wrflons = f.variables['XLONG'][0][:]
var = f.variables[varstr][:]
# four corners of domain
print wrflats.shape
print wrflons.shape
print wrflons[0].shape
wrflat_s = wrflats[0,len(wrflats)-1]
wrflat_n = wrflats[len(wrflats)-1,len(wrflons[0])-1]
wrflon_w = wrflons[0,0]
wrflon_e = wrflons[len(wrflats)-1,len(wrflons[0])-1]
z = 0 # assuming lowest level of model
# set up map
map = Basemap(projection='merc',llcrnrlon=wrflon_w,urcrnrlon=wrflon_e,llcrnrlat=wrflat_s,urcrnrlat=wrflat_n,resolution='i')
map.drawstates()
map.drawcounties()
map.drawcoastlines()
x,y = map(wrflons,wrflats)
# loop through times
for t in range(len(times)):
timestr = ''.join(times[t,:])
map.drawstates()
map.drawcounties()
map.drawcoastlines()
plt1 = map.pcolormesh(x,y,var[t,z,:,:],vmin=np.amin(var),vmax=np.amax(var))
colorbar = map.colorbar(plt1,"right", size="5%",pad="2%")
colorbar.set_label(f.variables[varstr].description+' '+f.variables[varstr].units)
plt.title('WRF output valid: '+timestr)
plt.savefig(outputdir+'/%03d_' % (t) +timestr+'_'+varstr+'.png')
plt.clf()
示例8: write_map_file
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def write_map_file(filename, known, unknown, width, height, dpi, labels_col, title):
data = unknown.append(known, True, False)
enlarge_by = 0.1
plt.figure(num=None, figsize=(width, height), dpi=dpi, facecolor="w", edgecolor="k")
data = data.loc[data.modern_lat != 0.0, :]
ll = data.modern_lat.min(), data.modern_lon.min()
ur = data.modern_lat.max(), data.modern_lon.max()
adj = tuple((ur[i] - ll[i]) * enlarge_by for i in range(2))
ll = tuple(ll[i] - adj[i] for i in range(2))
ur = tuple(ur[i] + adj[i] for i in range(2))
lat0 = ll[0] + ((ur[0] - ll[0]) / 2.0)
lon0 = ll[1] + ((ur[1] - ll[1]) / 2.0)
bmap = Basemap(
projection="merc",
resolution="l",
lon_0=lon0,
lat_0=90.0,
lat_ts=lat0,
llcrnrlat=ll[0],
llcrnrlon=ll[1],
urcrnrlat=ur[0],
urcrnrlon=ur[1],
)
bmap.shadedrelief()
bmap.drawmapboundary()
bmap.drawmeridians(np.arange(0, 360, 5), labels=[0, 0, 0, 1], fontsize=10)
bmap.drawparallels(np.arange(-90, 90, 5), labels=[1, 0, 0, 0], fontsize=10)
bmap.drawcounties(linewidth=1)
for disp, col in [("known", "c"), ("unknown", "m"), ("tentative", "b")]:
i = data.disposition == disp
lats = [lat for lat in list(data.loc[i, "modern_lat"]) if lat != 0.0]
lons = [lon for lon in list(data.loc[i, "modern_lon"]) if lon != 0.0]
x, y = bmap(lons, lats)
bmap.scatter(x, y, 8, marker="o", color=col, label=disp)
if filename:
labels = []
for s in data.loc[i, labels_col]:
labels.append(s if type(s) == unicode else u"")
for label, xi, yi in zip(labels, x, y):
plt.text(xi, yi, label)
plt.title(title)
plt.legend()
if filename:
plt.savefig(filename, dpi=dpi)
else:
plt.show()
示例9: drawMapOfSimilarityMatrix
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def drawMapOfSimilarityMatrix(graph, similarityMatrix, quality, targetCounty,
denominator, classesToDraw=5):
if quality == 'high':
basemapResolution = 'i'
DPI = 500
reliefScale = 1
figSize = (10, 5)
else:
basemapResolution = 'c'
DPI = 250
reliefScale = 0.5
figSize = (5, 2.5)
plt.figure(figsize=figSize)
m = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64, urcrnrlat=49,
projection='lcc', lat_1=33, lat_2=45, lon_0=-95,
resolution=basemapResolution)
m.shadedrelief(scale=reliefScale)
m.drawcoastlines()
m.drawstates()
m.drawcountries()
if quality == 'high':
m.drawcounties()
toDraw = similarityMatrix[targetCounty]
colors = getDivergingColorList(classesToDraw)
classBucketSize = 1 / float(classesToDraw - 1)
for county, matches in toDraw.iteritems():
x, y = m(graph.vs.find(name=county)["longitude"],
graph.vs.find(name=county)["latitude"])
percentSimilar = matches / float(denominator)
if percentSimilar == 1:
colorOffset = int(classesToDraw - 1)
else:
colorOffset = int(percentSimilar // classBucketSize)
m.scatter(x, y, 3, marker='o', color=colors[colorOffset])
mapName = "proportion-map-{0}-{1}.png".format(
targetCounty, datetime.datetime.today())
plt.savefig(mapName, dpi=DPI, bbox_inches='tight')
示例10: __include_basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def __include_basemap(self, ax, shpfile, POT, locs, colors, resolution='i', projection='tmerc', **basemap_kwargs):
from mpl_toolkits.basemap import Basemap
from matplotlib.patches import Polygon
if 'llcrnrlon' not in basemap_kwargs.keys():
basemap_kwargs.update({'llcrnrlon': self.ll.lon.min()-.01})
if 'llcrnrlat' not in basemap_kwargs.keys():
basemap_kwargs.update({'llcrnrlat': self.ll.lat.min()-.01})
if 'urcrnrlon' not in basemap_kwargs.keys():
basemap_kwargs.update({'urcrnrlon': self.ll.lon.max()+.01})
if 'urcrnrlat' not in basemap_kwargs.keys():
basemap_kwargs.update({'urcrnrlat': self.ll.lat.max()+.01})
if projection == 'tmerc':
if 'lat_0' not in basemap_kwargs.keys():
basemap_kwargs.update({'lat_0': (self.ll.lat.min()+self.ll.lat.max())/2.})
if 'lon_0' not in basemap_kwargs.keys():
basemap_kwargs.update({'lon_0': (self.ll.lon.min()+self.ll.lon.max())/2.})
map = Basemap(ax=ax, resolution=resolution, projection=projection, **basemap_kwargs)
parallels = np.arange(basemap_kwargs['llcrnrlat'], basemap_kwargs['urcrnrlat'],.1)
map.drawparallels(parallels,labels=[True,False,False,False])
meridians = np.arange(basemap_kwargs['llcrnrlon'], basemap_kwargs['urcrnrlon'],.1)
map.drawmeridians(meridians,labels=[False,False,False,True])
map.drawcounties()
if shpfile is not None:
map.readshapefile(shpfile, 'watersheds')
w_names = []
for shape_dict in map.watersheds_info:
w_names.append(shape_dict['GAGE_ID'])
for loc, c in zip(locs, colors):
seg = map.watersheds[w_names.index(loc)]
poly = Polygon(seg, facecolor=c,edgecolor=c, alpha=.5)
ax.add_patch(poly)
return map
示例11: grid_plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
def grid_plot(self):
"""
function for visualizing the generated grid
"""
lon, lat, dx, dy = self.rectilinear(self.nx,self.ny)
pdb.set_trace()
west=-95.42; east=-93.94
south=28.39; north=29.90
fig = plt.figure(figsize=(10,10))
basemap = Basemap(projection='merc',llcrnrlat=south,urcrnrlat=north,\
llcrnrlon=west,urcrnrlon=east, resolution='h')
basemap.drawcoastlines()
basemap.fillcontinents(color='coral',lake_color='aqua')
basemap.drawcountries()
basemap.drawcounties()
basemap.drawstates()
basemap.drawrivers(color='b')
llons, llats=basemap(lon,lat)
basemap.plot(llons, llats, color='k', ls='-', markersize=.5)
basemap.plot(llons.T, llats.T, color='k', ls='-', markersize=.5)
plt.show()
示例12: Basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
# Lambert Conformal map of Vermont
# LL: 42.611417, -73.672795
# UR: 45.086798, -71.244816
# Center: 43.8491075, -72.4588055
geoMap = Basemap(llcrnrlon=-73.672795, llcrnrlat=42.611417, urcrnrlon=-71.244816,
urcrnrlat=45.086798, projection='lcc', lat_0=43.8491075, lon_0=-72.4588055,
resolution='i', area_thresh=100)
# Draw the coastlines of continental area
geoMap.drawcoastlines()
# Draw country boundaries
geoMap.drawcountries(linewidth=2)
# Draw states boundaries (America only)
geoMap.drawstates(linewidth=2)
# Draw State county Boundaries
geoMap.drawcounties(linewidth=1)
# Fill the background (the oceans)
geoMap.drawmapboundary(fill_color='aqua')
# Fill the continental area
geoMap.fillcontinents(color='#70B870',lake_color='aqua')
# For Loop to add user locations.
state2LatLong = [['VT',44.0407,-72.7093]]
for i in range(len(state2LatLong)):
# Get the x,y coordinate for the geoplot. For whatever reason, it's Long / Lat instead
# of the standard Lat / Long.
x, y = geoMap(state2LatLong[i][2],state2LatLong[i][1])
plt.plot(x,y,'ro')
plt.text(x+10000,y+10000,state2LatLong[i][0], bbox=dict(facecolor='yellow',alpha=0.5))
示例13: Basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
# create figure and axes instances
fig = plt.figure(figsize=(16,16))
ax = fig.add_axes([0.1,0.1,0.9,0.9])
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'i' means use intermediate resolution coastlines.
# lon_0, lat_0 are the central longitude and latitude of the projection.
m = Basemap(llcrnrlon=-122.2332,llcrnrlat=37.0793,urcrnrlon=-121.4010,urcrnrlat=37.5141, \
rsphere=6371200.,resolution='h',projection='stere',lon_0=-122,lat_0=37.25, anchor='C')
# can get the identical map this way (by specifying width and
# height instead of lat/lon corners)
m.drawcoastlines()
m.drawcounties(linewidth=1)
m.fillcontinents(color='coral',lake_color='aqua')
# draw parallels and meridians.
m.drawmeridians(np.arange(-122,-120.,0.25), dashes=[3,3], color='b', labels=[0,0,0,1], ax=ax)
m.drawparallels(np.arange(37.,38.,0.25), dashes=[3,3], color='b', labels=[1,0,0,0], ax=ax)
m.drawmapboundary(fill_color='aqua')
# Pick up one user from the top 10 users.
user = result[4]['_id']
print user
# Extract all the locations this user added.
user_data = db.sj.find({'created.user':user})
pos_x = []
pos_y = []
i = 0
示例14: call
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
# set the colormap to jet.
#m.pcolormesh(x,y,data,shading='flat',cmap=plt.cm.jet)
# Add a colorbar/legend
cbar = m.colorbar(contour, ticks=[0.25, 1.0, 1.75, 2.75, 4.00])
cbar.ax.set_yticklabels(['Pea','Quarter','Golfball','Baseball','Grapefruit'])
################################################
# Build Map Features, like continents, states, #
# lat/lon lines, and other physical features #
################################################
m.drawcoastlines(linewidth=0.75,zorder=5)
m.fillcontinents(color='#e6e6e6',lake_color='#b3ffff')
m.drawcountries(linewidth=1.0,zorder=7)
m.drawstates(linewidth=0.5,zorder=6)
m.drawcounties(linewidth=0.3,color='gray',zorder=5)
m.drawmapboundary(fill_color='#b3ffff')
##############################################
# Add a title, and then show the plot. #
# Save the plot as images to disk if desired #
##############################################
plt.title('24-Hour Radar Hail Tracks\nEnding '+validtime+'')
plt.savefig('hail.png', dpi=300, bbox_inches='tight')
#plt.show()
print 'Finished creating image.'
viewimg = raw_input('Would you like to view the image? ')
if viewimg == 'y' or viewimg == 'yes':
call(["open", "hail.png"])
print 'Your image should appear. Enjoy your day!'
else:
示例15: mapAll
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcounties [as 别名]
#.........这里部分代码省略.........
lat_0, lon_0 (float): the center coordinates for the map. Default is
mean latitude/longitude in the list.
If the chosen projection doesn't support it, Basemap will
ignore the given values.
llcrnrlat, urcrnrlat, llcrnrlon, urcrnrlon (float): The coordinates
of the two opposite corners of the rectangle.
countries (bool): Draws the countries border. Defaults is off (False).
counties (bool): Draws the USA counties. Default is off (False).
rivers (bool): Draws the rivers. Default is off (False).
states (bool): Draws the American and Australian states borders.
Default is off (False).
background (string): Plots one of the following images on the map:
bluemarble, etopo, shadedrelief, or none (filled continents).
Default is none.
scale (float): Useful to downgrade the original image resolution to
speed up the process. Default is 0.5.
palette (dict): A dictionary of plotting color/marker by criteria. The
keys should correspond to ***unique*** criteria with a list of
associated values. The list should be in the format
['color', 'marker'].
markersize (int): The size of the marker.
figsize (list): the size for the figure
ax: Return as axis instead of figure (useful to integrate plot into a subplot)
Returns:
The figure
"""
#Check that the lists have the same length and convert to numpy arrays
if len(lat)!=len(lon) or len(lat)!=len(criteria) or len(lon)!=len(criteria):
sys.exit("Latitude, Longitude, and criteria list must be the same" +\
"length")
# Grab the center latitude/longitude
if not lat_0:
lat_0 = np.mean(np.array(lat))
if not lon_0:
lon_0 = np.mean(np.array(lon))
# If palette is not given, then make a random one.
if not palette:
marker_list = ['o','v','^','<','>','8','s','p','*','h','D']
color_list = ['#FFD600','#FF8B00','k','#86CDFA','#00BEFF','#4169E0',\
'#8A4513','r','#FF1492','#32CC32','#FFD600','#2F4F4F']
# select at random for unique entries in criteria
marker = [random.choice(marker_list) for _ in range(len(set(criteria)))]
color = [random.choice(color_list) for _ in range(len(set(criteria)))]
crit_unique = [crit for crit in set(criteria)]
#initialize the palette
palette = {crit_unique[0]:[color[0],marker[0]]}
for i in range(len(crit_unique)):
d1 = {crit_unique[i]:[color[i],marker[i]]}
palette.update(d1)
#Make the figure
if not ax:
fig, ax = plt.subplots(figsize=figsize)
map = Basemap(projection = projection, lat_0 = lat_0, lon_0 = lon_0,\
llcrnrlat=llcrnrlat, urcrnrlat=urcrnrlat,\
llcrnrlon=llcrnrlon, urcrnrlon=urcrnrlon)
map.drawcoastlines()
# Background
if background == "shadedrelief":
map.shadedrelief(scale = scale)
elif background == "bluemarble":
map.bluemarble(scale=scale)
elif background == "etopo":
map.etopo(scale=scale)
elif background == "none":
map.fillcontinents(color='0.9', lake_color = 'w')
else:
sys.exit("Enter either 'shadedrelief','bluemarble','etopo',or'None'")
#Other extra information
if countries == True:
map.drawcountries()
if counties == True:
map.drawcounties()
if rivers == True:
map.drawrivers()
if states == True:
map.drawrivers()
# Get the indexes by criteria
for crit in set(criteria):
# Grab the indices with same criteria
index = [i for i,x in enumerate(criteria) if x == crit]
X,Y =map(np.array(lon)[index],np.array(lat)[index])
map.scatter(X,Y,
s= markersize,
facecolor = palette[crit][0],
marker = palette[crit][1],
zorder = 10,
label = crit)
plt.legend(loc = 'center', bbox_to_anchor=(1.25,0.5),scatterpoints = 1,
frameon = False, fontsize = 8, markerscale = 0.7)
return ax