本文整理汇总了Python中matplotlib.toolkits.basemap.Basemap.plot方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.plot方法的具体用法?Python Basemap.plot怎么用?Python Basemap.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.plot方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Basemap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
urcrnrlon = llcrnrlon+(array.shape[1]-1)*coords[1]
urcrnrlat = coords[3]
llcrnrlat = urcrnrlat+(array.shape[0]-1)*coords[5]
# create Basemap instance.
m = Basemap(llcrnrlon=llcrnrlon,llcrnrlat=llcrnrlat,urcrnrlon=urcrnrlon,urcrnrlat=urcrnrlat,projection='cyl')
# create a figure, add an axes
# (leaving room for a colorbar).
fig = p.figure()
ax = fig.add_axes([0.1,0.1,0.75,0.75])
# plot image from DEM over map.
im = m.imshow(array,origin='upper')
# make a colorbar.
cax = p.axes([0.875, 0.1, 0.05, 0.75]) # setup colorbar axes.
p.colorbar(cax=cax) # draw colorbar
p.axes(ax) # make the original axes current again
# draw meridians and parallels.
m.drawmeridians(p.linspace(llcrnrlon+0.1,urcrnrlon-0.1,5),labels=[0,0,0,1],fmt='%4.2f')
m.drawparallels(p.linspace(llcrnrlat+0.1,urcrnrlat-0.1,5),labels=[1,0,0,0],fmt='%4.2f')
# plot county boundaries from
# http://edcftp.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz
shp_info = m.readshapefile('countyp020','counties',drawbounds=True,linewidth=1.0)
# plot some cities.
lons = [-105.22,-105.513,-105.316,-105.47]; lats = [39.76,39.801,39.633,39.41]
names = ['Golden','Central City','Evergreen','Bailey']
x,y = m(lons,lats)
m.plot(x,y,'ko')
for name,xx,yy in zip(names,x,y):
p.text(xx+0.01,yy+0.01,name)
p.title(gd.GetDescription()+' USGS DEM with county boundaries')
p.show()
示例2: Basemap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
lonmin = b*math.floor(min(lon)/b)
lonmax = b*math.ceil(max(lon)/b)
latmin = b*math.floor(min(lat)/b)
latmax = b*math.ceil(max(lat)/b)
meridian = (range(lonmin, lonmax+b, b))
parallel = (range(latmin, latmax+b, b))
prj = 'cyl'
res = 'i'
map = Basemap(projection=prj,
llcrnrlon=lonmin,
llcrnrlat=latmin,
urcrnrlon=lonmax,
urcrnrlat=latmax,
resolution=res)
map.plot(lon, lat, 'r-')
map.plot(lon, lat, 'k+')
fs = 10
pylab.text(115.9,-31.9, "Perth", fontsize=fs, ha='left', va='top')
pylab.text(114.1,-21.9, "Exmouth", fontsize=fs, ha='left', va='top')
pylab.text(118.5,-20.4, "Port Hedland", fontsize=fs, ha='left', va='top')
pylab.text(130.8,-12.6, "Darwin", fontsize=fs, ha='left', va='top')
pylab.text(145.75,-16.9, "Cairns", fontsize=fs, ha='right', va='top')
pylab.text(149.2,-21.2, "Mackay", fontsize=fs, ha='right', va='top')
pylab.text(153.0,-27.5, "Brisbane", fontsize=fs, ha='right', va='top')
pylab.text(153.1,-30.25, "Coffs Harbour", fontsize=fs, ha='right', va='top')
pylab.text(151.1,-33.9, "Sydney", fontsize=fs, ha='right', va='top')
pylab.text(150.5,-35.3, "Ulladulla", fontsize=fs, ha='right', va='top')
map.fillcontinents(color='0.9')
示例3: region
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
# in which direction to depart for other points on earth and how far
# it will be to reach that destination.
# The specified point shows up as a red dot in the center of the map.
# This example shows how to use the width and height keywords
# to specify the map projection region (instead of specifying
# the lat/lon of the upper right and lower left corners).
# user enters the lon/lat of the point, and it's name
lon_0 = float(raw_input('input reference lon (degrees):'))
lat_0 = float(raw_input('input reference lat (degrees):'))
location = raw_input('name of location:')
# use these values to setup Basemap instance.
width = 28000000
m = Basemap(width=width,height=width,\
resolution='c',projection='aeqd',\
lat_0=lat_0,lon_0=lon_0)
# draw coasts and fill continents.
m.drawcoastlines(linewidth=0.5)
m.fillcontinents()
# 20 degree graticule.
m.drawparallels(arange(-80,81,20))
m.drawmeridians(arange(-180,180,20))
# draw a red dot at the center.
xpt, ypt = m(lon_0, lat_0)
m.plot([xpt],[ypt],'ro')
# draw the title.
title('The World According to Garp in '+location)
show()
示例4: int
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
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)
# create the figure.
fig=figure(figsize=(8,8))
# add an axes, leaving room for colorbar on the right.
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map with imshow.
im = m.imshow(topodat,cm.jet)
# setup colorbar axes instance.
l,b,w,h = ax.get_position()
cax = axes([l+w+0.075, b, 0.05, h])
colorbar(tickfmt='%d', cax=cax) # draw colorbar
axes(ax) # make the original axes current again
# plot blue dot on boulder, colorado and label it as such.
xpt,ypt = m(-104.237,40.125)
m.plot([xpt],[ypt],'bo')
text(xpt+100000,ypt+100000,'Boulder')
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()
# draw parallels and meridians.
# label on left, right and bottom of map.
parallels = arange(0.,80,20.)
m.drawparallels(parallels,labels=[1,1,0,1])
meridians = arange(10.,360.,30.)
m.drawmeridians(meridians,labels=[1,1,0,1])
# set title.
title('ETOPO Topography - Lambert Conformal Conic')
show()
示例5: pcolor
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
ax = fig.add_axes([0.1, 0.1, 0.7, 0.7])
# plot image over map with imshow.
im = m.imshow(topodat, cm.jet)
# use pcolor (looks very similar to imshow, but slower).
# p = m.pcolor(x,y,topodat,shading='flat')
# plot contour lines over map (colors is a list so neg contours will
# not be dashed).
# levels, colls = m.contour(x,y,topodat,15,linewidths=0.5,colors=['k','k'])
# fill the contours.
# levels, colls = m.contourf(x,y,topodat,15,cmap=cm.jet,colors=None)
cax = axes([0.875, 0.1, 0.05, 0.7]) # setup colorbar axes
colorbar(tickfmt="%d", cax=cax) # draw colorbar
axes(ax) # make the original axes current again
# plot blue dot on boulder, colorado and label it as such.
xpt, ypt = m(-104.237, 40.125)
m.plot([xpt], [ypt], "bo")
text(xpt + 100000, ypt + 100000, "Boulder")
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()
# draw parallels and meridians.
# label on left, right and bottom of map.
parallels = arange(0.0, 80, 20.0)
m.drawparallels(parallels, labels=[1, 1, 0, 1])
meridians = arange(10.0, 360.0, 30.0)
m.drawmeridians(meridians, labels=[1, 1, 0, 1])
title("ETOPO Topography - Lambert Conformal Conic")
show()
示例6: Basemap
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
mapobj= Basemap(projection='merc',lat_0=(box[2]+box[3])/2.0, lon_0=(box[0]+box[1])/2.0,llcrnrlat=box[2], llcrnrlon=box[0], urcrnrlat=box[3] , urcrnrlon=box[1], resolution='l',area_thresh=1., lat_ts=(box[2]+box[3])/2.0)
longr, latgr=meshgrid(lons,lats)
xx, yy = mapobj(longr, latgr)
mapobj.drawmapboundary()
mapobj.readshapefile('/flurry/home/scollis/shapes/cstntcd_r','coast',drawbounds=True,linewidth=0.5,color='k',antialiased=1,ax=None)
mapobj.contour(xx,yy,angs, levels=[150,30], colors=['r'])
mapobj.drawmeridians(array([130.2, 130.4, 130.6, 130.8,131.0,131.2, 131.4]), labels=[1,0,0,1])
mapobj.drawparallels(array([--12.8, -12.6, -12.4, -12.2, -12.0, -11.8, -11.6, -11.4]), labels=[1,0,0,1])
dd_box_xx, dd_box_yy=mapobj(array([dd_box[0], dd_box[1]]),array([dd_box[2], dd_box[3]]))
xy=dd_box_xx[0], dd_box_yy[0]
width, height= dd_box_xx[1]-dd_box_xx[0], dd_box_yy[1]-dd_box_yy[0]
my_patch=matplotlib.patches.Rectangle(xy, width, height, edgecolor='blue', facecolor='white')
ax=gca()
ax.add_patch(my_patch)
radar_xx, radar_yy=mapobj(array([ber_loc[1], gp_loc[1]]), array([ber_loc[0], gp_loc[0]]))
mapobj.plot(radar_xx, radar_yy, 'bo')
ax.text(radar_xx[0]+1000.0, radar_yy[0]-3000.0, 'Berrimah')
ax.text(radar_xx[1]+1000.0, radar_yy[1]-3000.0, 'Gunn Point')
savefig('/flurry/home/scollis/results/area_vis.png')
close(f)
|
| ================= ==============================================
| Property Description
| ================= ==============================================
| alpha float
| animated [True | False]
| antialiased or aa [True | False]
| clip_box a matplotlib.transform.Bbox instance
示例7: wrf_grid
# 需要导入模块: from matplotlib.toolkits.basemap import Basemap [as 别名]
# 或者: from matplotlib.toolkits.basemap.Basemap import plot [as 别名]
def wrf_grid(
# WPS -> map_proj
projection,
# WPS -> truelat1
lat_1,
# WPS -> truelat2
lat_2,
# WPS -> stand_lon
lon_0,
# WPS -> ref_lat
grid_centre_lat,
# WPS -> ref_lon
grid_centre_lon,
delta_x,
delta_y,
# WPS -> e_we
nx,
# WPS -> e_sn
ny,
show_mass_grid = False,
show_stag_grids = False,
):
if lon_0 != grid_centre_lon:
print 'not implemented yet -> see the source'
print "\tbut let's try it anyways..."
#return
width = nx * delta_x
height = ny * delta_y
frame_x = 10 * delta_x
frame_y = 10 * delta_y
m = Basemap(
lat_0 = grid_centre_lat,
# this could be a bad assumption... because lon_0 and grid_centre_lon
# need not be aligned, but at the same time I need to give this to
# basemap for the grid to be centred... I could probably fix it
# assigning lon_0 and then imposing a grid shift in native coordinates
# if ref_lon and lon_0 were not the same
lon_0 = lon_0,
lat_1 = lat_1,
lat_2 = lat_2,
width = width + 2*frame_x,
height = height + 2*frame_y,
resolution = 'l',
area_thresh=1000.
)
grid_centre_x, grid_centre_y = m(grid_centre_lon, grid_centre_lat)
min_x = grid_centre_x - width/2.
min_y = grid_centre_y - height/2.
max_x = min_x + width
max_y = min_y + height
x = n.arange(min_x, max_x + a_small_number, delta_x)
y = n.arange(min_y, max_y + a_small_number, delta_y)
x = x[1:-1]
y = y[1:-1]
x_u = n.arange(min_x, max_x + delta_x + a_small_number, delta_x)
x_u -= delta_x/2.
x_u = x_u[1:-1]
y_v = n.arange(min_y, max_y + delta_y + a_small_number, delta_y)
y_v -= delta_y/2.
y_v = y_v[1:-1]
X, Y = p.meshgrid(x,y)
lon, lat = m(X, Y, inverse=True)
X_u, Y_u = p.meshgrid(x_u,y)
lon_u, lat_u = m(X_u, Y_u, inverse=True)
X_v, Y_v = p.meshgrid(x,y_v)
lon_v, lat_v = m(X_v, Y_v, inverse=True)
if show_mass_grid:
m.plot(X, Y, 'b+')
m.plot([grid_centre_x], [grid_centre_y], 'r+')
if show_stag_grids:
m.plot(X_u, Y_u, 'g+')
m.plot(X_v, Y_v, 'r+')
m.drawcoastlines()
p.show()
output = {
'map' : m,
'mass_stag': {
'lon_2d' : lon,
'lat_2d' : lat,
'x' : x,
'y' : y,
'x_2d' : X,
'y_2d' : Y,
},
'u_stag': {
'lon_2d' : lon_u,
'lat_2d' : lat_u,
'x' : x_u,
'y' : y,
'x_2d' : X_u,
'y_2d' : Y_u,
},
'v_stag': {
'lon_2d' : lon_v,
'lat_2d' : lat_v,
'x' : x,
'y' : y_v,
'x_2d' : X_v,
'y_2d' : Y_v,
#.........这里部分代码省略.........