本文整理汇总了Python中mpl_toolkits.basemap.Basemap.counties方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.counties方法的具体用法?Python Basemap.counties怎么用?Python Basemap.counties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.counties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stat_spatial
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import counties [as 别名]
def stat_spatial(ifile0, ifile1, funcs = __all__, variables = ['O3'], counties = False):
"""
ifile0 - left hand side of equation
ifile1 - right hand side of equation
variables - list of variables to plot
"""
from mpl_toolkits.basemap import Basemap
from matplotlib.pyplot import figure, show
lonlatcoords = getattr(ifile0, 'lonlatcoords', getattr(ifile1, 'lonlatcoords', ''))
lon, lat = np.array(map(lambda x: map(float, x.split(',')), lonlatcoords.split('/'))).T
latmin, latmax = lat.min(), lat.max()
lonmin, lonmax = lon.min(), lon.max()
bmap = Basemap(llcrnrlat = latmin, llcrnrlon = lonmin, urcrnrlat = latmax, urcrnrlon = lonmax, resolution = 'i')
for vark in variables:
for statname in funcs:
statfunc = eval(statname)
fig = figure()
ax = fig.add_subplot(111)
ax.set_title(vark + ' ' + statname)
var_0 = ifile0.variables[vark]
var_1 = ifile1.variables[vark]
try:
pidx = list(var_0.dimensions).index('points')
except:
pidx = list(var_1.dimensions).index('points')
statvs = []
for sitei in range(var_0.shape[pidx]):
val_0 = var_0[:].take([sitei], axis = pidx).ravel()
val_1 = var_1[:].take([sitei], axis = pidx).ravel()
statvs.append(statfunc(val_0, val_1))
dots = bmap.scatter(x = lon, y = lat, c = statvs, ax = ax, cmap = 'jet')
bmap.drawcoastlines(ax = ax)
bmap.drawcountries(ax = ax)
bmap.drawstates(ax = ax)
fig.colorbar(dots)
if counties: bmap.counties(ax = ax)
show()