当前位置: 首页>>代码示例>>Python>>正文


Python Basemap.ax方法代码示例

本文整理汇总了Python中matplotlib.toolkits.basemap.Basemap.ax方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.ax方法的具体用法?Python Basemap.ax怎么用?Python Basemap.ax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.toolkits.basemap.Basemap的用法示例。


在下文中一共展示了Basemap.ax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: shiftgrid

# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import ax [as 别名]
lons = NX.array(load('etopo20lons.gz'),'d')
lats = NX.array(load('etopo20lats.gz'),'d')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)

# setup of basemap ('lcc' = lambert conformal conic).
# use major and minor sphere radii from WGS84 ellipsoid.
m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
            rsphere=(6378137.00,6356752.3142),\
            resolution='l',area_thresh=1000.,projection='lcc',\
            lat_1=50.,lon_0=-107.)
# create figure.
fig = Figure()
canvas = FigureCanvas(fig)
# set 'ax' instance variable so pylab won't be imported.
m.ax = fig.add_axes([0.1,0.1,0.7,0.7])
# reset figure size to have same aspect ratio as map.
# fig will be 8 inches wide.
# (don't use createfigure, since that imports pylab).
if m.aspect <= 1.:
    fig.set_figsize_inches((8,m.aspect*8.))
else:
    fig.set_figsize_inches((8/m.aspect,8.))
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat,x,y = m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True)
# plot image over map with imshow.
im = m.imshow(topodat,cm.jet)
cax = fig.add_axes([0.875, 0.1, 0.05, 0.7],frameon=False) # setup colorbar axes
fig.colorbar(im,tickfmt='%d', cax=cax) # draw colorbar
# plot blue dot on boulder, colorado and label it as such.
开发者ID:,项目名称:,代码行数:33,代码来源:


注:本文中的matplotlib.toolkits.basemap.Basemap.ax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。