本文整理汇总了Python中mpl_toolkits.basemap.Basemap.shadedrelief方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.shadedrelief方法的具体用法?Python Basemap.shadedrelief怎么用?Python Basemap.shadedrelief使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.shadedrelief方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_evolution
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def plot_evolution():
m = Basemap(projection='mill',
llcrnrlon=73. ,llcrnrlat=20,
urcrnrlon=135. ,urcrnrlat=55.)
m.shadedrelief()
plt.title('Evolution of a Feed')
evolution = np.load('/Users/richard/classes/294-1/project/src/locations.npy')
lon, lat = locations[:, 3], locations[:, 2]
x, y = m(lon, lat)
#zipped = zip(x,y)
#shuffle(zipped)
#unzipped = [list(t) for t in zip(*zipped)]
#x, y = unzipped[0], unzipped[1]
colors = []
i = 0
for row in locations:
if row[0] == 0:
colors.append('b')
else:
i += 1
colors.append('r')
m.scatter(x,y,color=colors,s=20,marker="o")
plt.show()
示例2: initmap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def initmap(gps):
# Generate Map Dimensions
zoom = 1 # je größer, desto größer der Ausschnitt
coords = gps.get_coordinates()
lat0=coords.latitude/1000000.0
lon0=coords.longitude/1000000.0
llcrnrlon=lon0-(4.0*zoom) # links
llcrnrlat=lat0-(2.1*zoom) # unten
urcrnrlon=lon0+(5.0*zoom) # rechts
urcrnrlat=lat0+(1.2*zoom) # oben
print('Generating Map...')
# First set up the figure, the axis, and the plot element we want to animate
fig = plt.figure(figsize=(16,9))
ax=fig.add_axes([0.01,0.01,0.98,0.98])
# Thanks to this great tutorial:
# http://peak5390.wordpress.com/2012/12/08/mapping-global-earthquake-activity-a-matplotlib-basemap-tutorial/
m = Basemap(llcrnrlon=llcrnrlon,llcrnrlat=llcrnrlat,urcrnrlon=urcrnrlon,urcrnrlat=urcrnrlat,
resolution='l',projection='tmerc',lon_0=lon0,lat_0=lat0)
m.drawcoastlines()
#m.fillcontinents(color='gray')
# draw parallels and meridians.
m.drawparallels(np.arange(-40,61.,2.))
m.drawmeridians(np.arange(-30.,43.,2.))
m.drawmapboundary()
m.drawcountries()
m.shadedrelief()
return fig, plt, m
示例3: show_route
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [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()
示例4: mapfig
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def mapfig(ax=plt.gca()):
m = Basemap(projection='merc',llcrnrlat=-26,urcrnrlat=-8,llcrnrlon=-18,urcrnrlon=16,resolution='l',ax=ax)
m.drawcoastlines()
m.drawmeridians(np.linspace(-28,16,9),labels=[0,0,0,1],linewidth=0.1)
m.drawparallels(np.linspace(-26,-8,10),labels=[1,0,0,0],linewidth=0.1)
m.shadedrelief(alpha=0.4)
return m
示例5: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def plot(text, size):
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# setup Lambert Conformal basemap.
m = Basemap(width=3000000,height=3000000,projection='lcc',
resolution='c',lat_0=18,lon_0=78)
m.drawcoastlines()
#m.fillcontinents(color='coral',lake_color='aqua')
m.shadedrelief()
colors = numpy.random.rand(30,3)
lat = [17.38,13.08,12.98,19.07,22.57,26.84,26.91,28.63]
lon = [78.49,80.28,77.61,72.88,88.34,80.95,75.78,77.25]
df_x = [0.5,0,0.5]
df_y = [-0.5,0,-0.5]
f_lat = []
f_lon = []
f_size = []
f_color = []
for place_id in range(len(lat)):
for i in range(3):
f_lat.append(lat[place_id] + df_y[i])
f_lon.append(lon[place_id] + df_x[i])
f_size.append(size[place_id][i]*500)
f_color.append(colors[text[place_id][i]])
#m.plot(lon[place_id]+df_y[i],lat[place_id]+ df_x[i], 'bo',markersize = size[place_id][i], latlon = True)
m.scatter(f_lon, f_lat, s = f_size, c = f_color, alpha = 0.5, latlon = True)
m.scatter(lon, lat, s = 8000, c = 'b', alpha = 0.2, latlon = True)
#m.scatter(f_lon, f_lat, s = f_size, c = f_color, latlon = True)
#m.plot(f_lon,f_lat,'bo',markersize = 5, latlon = True)
plt.show()
示例6: rendermap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def rendermap(projection):
'''
For sinu, moll, hammer, npstere, spstere, nplaea, splaea, npaeqd,
spaeqd, robin, eck4, kav7, or mbtfpq, the values of
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, width and height
are ignored (because either they are computed internally,
or entire globe is always plotted).
'''
m=Basemap(llcrnrlon=-12.0, \
llcrnrlat=32.0, \
urcrnrlon=54.4, \
urcrnrlat=65.3, \
llcrnrx=None, \
llcrnry=None, \
urcrnrx=None, \
urcrnry=None, \
width=None, \
height=None, \
projection=projection, \
resolution='h', \
area_thresh=1000, \
rsphere=6370997.0, \
ellps=None, \
lat_ts=None, \
lat_1=None, \
lat_2=None, \
lat_0=51.0, \
lon_0=13.0, \
lon_1=None, \
lon_2=None, \
o_lon_p=None, \
o_lat_p=None, \
k_0=None, \
no_rot=True, \
suppress_ticks=True, \
satellite_height=35786000, \
boundinglat=None, \
fix_aspect=True, \
anchor='C', \
celestial=False, \
round=False, \
epsg=None, \
ax=None)
m.drawcountries(linewidth=0.2, linestyle='solid', color='w', antialiased=1, ax=None, zorder=None)
m.drawparallels(np.arange(-90.,120.,10.),labels=[0,0,0,0],linewidth=0.2) # draw parallels
m.drawmeridians(np.arange(0.,420.,10.),labels=[0,0,0,0],linewidth=0.2) # draw meridians
m.shadedrelief()
plt.title('\'' + projection + '\' Projection', fontsize=12)
plt.savefig(fname, dpi=300, bbox_inches='tight', transparent=True)
plt.close()
print('Saved \'' + fname + '\'')
示例7: show_coord_topo
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def show_coord_topo(windpark, title, show = True):
"""Plot the topology of a given windpark
Topographic Map with farms
see: http://matplotlib.org/basemap/users/examples.html
Basemap
Parameters
----------
windpark : Windpark
A given windpark to show the topology.
"""
turbines = windpark.get_turbines()
target = windpark.get_target()
radius = windpark.get_radius()
#pack latitude and longitude in lists
rel_input_lat = []
rel_input_lon = []
for row in turbines:
rel_input_lat.append(np.float64(row.latitude))
rel_input_lon.append(np.float64(row.longitude))
targetcoord = [0.0, 0.0]
targetcoord[0] = np.float64(target.latitude)
targetcoord[1] = np.float64(target.longitude)
graddiff = (radius/111.0) + 0.3 # degree in km
m = Basemap(fix_aspect=False, projection='stere', lon_0=targetcoord[1], lat_0=targetcoord[0],\
llcrnrlon = targetcoord[1]-graddiff, llcrnrlat = targetcoord[0]-graddiff ,\
urcrnrlon = targetcoord[1]+graddiff, urcrnrlat = targetcoord[0]+graddiff ,\
rsphere=6371200., resolution = 'l', area_thresh=1000)
# Target
x_target,y_target = m(targetcoord[1],targetcoord[0])
# Input Farms
rel_inputs_lon, rel_inputs_lat = m(rel_input_lon, rel_input_lat)
# labels = [left,right,top,bottom]
parallels = np.arange(int(targetcoord[0]-3), int(targetcoord[0]+3), 1.)
#m.drawparallels(parallels,labels=[False,True,True,False])
meridians = np.arange(int(targetcoord[1]-3), int(targetcoord[1]+3), 1.)
#m.drawmeridians(meridians,labels=[True,False,False,True])
# plot farms in the radius
m.scatter(rel_inputs_lon, rel_inputs_lat,20, marker='o', color="#000000")
m.scatter(x_target, y_target, 20, marker='o', color="r")
m.shadedrelief()
plt.title(title)
if(show):
plt.show()
示例8: main
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def main():
trip_data = data_utils.load_trip_data()
station_data = data_utils.load_station_data()
zip_data = data_utils.load_zip_data()
trip_coordinates_zip = data_utils.get_trip_coordinates_zip(trip_data, station_data)
trip_coordinates_home_coordinates = data_utils.get_trip_coordinates_home_coordinates(trip_coordinates_zip, zip_data)
home_coordinates = zip(*trip_coordinates_home_coordinates)[2]
#home_coordinates = filter(data_utils.is_bay_area_resident, home_coordinates)
lat, lon = zip(*home_coordinates)
# m = Basemap(projection='merc',llcrnrlat=-80,urcrnrlat=80,\
# llcrnrlon=-180,urcrnrlon=180,lat_ts=20,resolution='c') #World
# m = Basemap(projection='merc',llcrnrlat=25,urcrnrlat=50,\
# llcrnrlon=-130,urcrnrlon=-70,lat_ts=20,resolution='c') #USA
# m = Basemap(projection='merc',llcrnrlat=35.5,urcrnrlat=39.9,\
# llcrnrlon=-124.5,urcrnrlon=-118.5,lat_ts=20,resolution='c') #Norcal
m = Basemap(projection='merc',llcrnrlat=37.304294,urcrnrlat=37.840926,\
llcrnrlon=-122.559453,urcrnrlon=-121.859292,lat_ts=20,resolution='c') #Bay Area
m.shadedrelief()
#m.drawlsmask()
#m.drawcoastlines()
m.drawcountries()
m.drawstates()
#m.fillcontinents(color='0.8')
# draw parallels and meridians.
#m.drawparallels(np.arange(-90.,91.,30.))
#m.drawmeridians(np.arange(-180.,181.,60.))
#m.drawmapboundary(fill_color='aqua')
xs,ys = m(lon,lat)
m.plot(xs, ys, latlon=False, linestyle='circle marker', marker='o', markerfacecolor='blue', markersize=5)
#start_coordinates = zip(*trip_coordinates_home_coordinates)[0]
#lat, lon = zip(*start_coordinates)
#xs,ys = m(lon,lat)
#m.plot(xs, ys, latlon=False, linestyle='circle marker', marker='o', markerfacecolor='green', markersize=5)
#end_coordinates = zip(*trip_coordinates_home_coordinates)[1]
#lat, lon = zip(*end_coordinates)
#xs,ys = m(lon,lat)
#m.plot(xs, ys, latlon=False, linestyle='circle marker', marker='o', markerfacecolor='red', markersize=5)
plt.show()
示例9: geramapa
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def geramapa(idx):
lon = stars[idx].ra - datas[idx].sidereal_time('mean', 'greenwich')
m = Basemap(projection='ortho',lat_0=stars[idx].dec.value,lon_0=lon.value,resolution='l')
# draw coastlines, country boundaries, fill continents.
m.shadedrelief()
m.drawcoastlines(linewidth=0.25)
m.drawcountries(linewidth=0.4)
m.drawstates(linewidth=0.4)
#m.fillcontinents(color='coral',lake_color='aqua')
# draw the edge of the map projection region (the projection limb)
#m.drawmapboundary(fill_color='aqua')
# draw lat/lon grid lines every 30 degrees.
m.drawmeridians(np.arange(0,360,30))
m.drawparallels(np.arange(-90,90,30))
if os.path.isfile(sitearq) == True:
xpt,ypt = m(sites['lon'],sites['lat'])
m.plot(xpt,ypt,'bo')
CS=m.nightshade(datas[idx].datetime, alpha=0.2)
a, b =m(lon.value, stars[idx].dec.value)
a = a*u.m
b = b*u.m
dista = (dist[idx].to(u.km)*ca[idx].to(u.rad)).value*u.km
disterr = (dist[idx].to(u.km)*erro.to(u.rad)).value*u.km
ax = a + dista*np.sin(pa[idx])
ax2 = ax + 1000*u.km*vec*np.cos(pa[idx])
ax3 = ax2 - tamanho/2*np.sin(pa[idx])
ax4 = ax2 + tamanho/2*np.sin(pa[idx])
ax5 = a + (dista-disterr)*np.sin(pa[idx]) + 1000*u.km*vec*np.cos(pa[idx])
ax6 = a + (dista+disterr)*np.sin(pa[idx]) + 1000*u.km*vec*np.cos(pa[idx])
by = b + dista*np.cos(pa[idx])
by2 = by - 1000*u.km*vec*np.sin(pa[idx])
by3 = by2 - tamanho/2*np.cos(pa[idx])
by4 = by2 + tamanho/2*np.cos(pa[idx])
by5 = b + (dista-disterr)*np.cos(pa[idx]) - 1000*u.km*vec*np.sin(pa[idx])
by6 = b + (dista+disterr)*np.cos(pa[idx]) - 1000*u.km*vec*np.sin(pa[idx])
m.plot(ax,by, 'ro', markersize=20)
m.plot(ax2.to(u.m),by2.to(u.m), 'ro', markersize=8)
m.plot(ax3.to(u.m), by3.to(u.m), 'b')
m.plot(ax4.to(u.m), by4.to(u.m), 'b')
m.plot(ax5.to(u.m), by5.to(u.m), 'r--')
m.plot(ax6.to(u.m), by6.to(u.m), 'r--')
fig = plt.gcf()
fig.set_size_inches(18.0, 15.0)
plt.title('-{} D={}- dots each 1000km or {:.2f} <> offsets (mas): {:.1f}, {:.1f}\n'.format(obj, tamanho, np.absolute(1000*u.km/vel[idx]), off_ra[idx].value, off_de[idx].value), fontsize=25, fontproperties='FreeMono')
plt.xlabel('\n year-m-d h:m:s UT ra__dec__J2000__candidate C/A P/A vel Delta R* K* long\n\
{} {:02d} {:02d} {:07.4f} {:+02d} {:02d} {:06.3f} {:6.3f} {:6.2f} {:6.2f} {:5.2f} {:5.1f} {:4.1f} {:3.0f}'
.format(datas[idx].iso, dados['afh'][idx], dados['afm'][idx], dados['afs'][idx], dados['ded'][idx], dados['dem'][idx], dados['des'][idx], ca[idx].value, pa[idx].value, dados['vel'][idx],
dist[idx].value, dados['mR'][idx], dados['mK'][idx], dados['long'][idx]), fontsize=21, fontproperties='FreeMono')
plt.savefig('{}_{}.png'.format(obj, datas[idx].isot),dpi=100)
print 'Gerado: {}_{}.png'.format(obj, datas[idx].isot)
plt.clf()
示例10: render_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def render_map(grb_file, llclat, llclon, urclat, urclon, altitude_layer):
"""Given a grb file, renders a jpg map on disk."""
print('processing file %s ' % grb_file)
grbs = pygrib.open(grb_file)
data = grbs.select(name='Temperature')[altitude_layer]['values']
plt.figure(figsize=(12, 12))
# We don't like the way noaa aligns things. We like monotonic variations.
data = realign_noaa_data(data)
lonlat2temp = interpolate.interp2d(ALL_LONS, ALL_LATS, data, kind='linear')
lats_interp = np.arange(llclat, urclat, 0.01)
lons_interp = np.arange(llclon, urclon, 0.01)
data_interp = lonlat2temp(lons_interp, lats_interp)
# Size of the img to render in meters.
width, height = width_height_from_bbox(llclat, llclon, urclat, urclon)
m = Basemap(
projection='cass',
lat_ts=10,
lat_0=(urclat + llclat) / 2,
lon_0=(llclon + urclon) / 2,
resolution='i',
width=width,
height=height)
x, y = m(*np.meshgrid(lons_interp, lats_interp))
# Draw plenty of fancy stuff
m.drawstates()
m.drawcountries()
m.drawlsmask()
m.drawrivers()
m.drawcoastlines()
m.shadedrelief()
m.drawparallels(np.arange(-90., 120., 30.), labels=[1, 0, 0, 0])
m.drawmeridians(np.arange(-180., 180., 60.), labels=[0, 0, 0, 1])
m.pcolormesh(
x,
y,
data_interp,
shading='flat',
cmap=plt.cm.jet,
alpha=0.05,
vmin=260,
vmax=305)
m.colorbar(location='right')
plt.title('Temperature')
image = '%s.jpg' % grb_file
plt.savefig(image)
plt.close()
示例11: globe_tweet
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def globe_tweet(rot=0,time=0):
m = Basemap(projection='ortho', lon_0=rot, lat_0=20, resolution='c')
m.shadedrelief(scale=0.1)
m.drawcoastlines(color='0.4')
m.drawcountries(color='0.4')
m.fillcontinents(color='white',lake_color='gray')
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(0., 360., 60.))
m.drawmapboundary(fill_color='0.8')
lon=t_lon[time]
lat=t_lat[time]
x,y=m(lon,lat)
m.plot(x,y,'bo',markersize=9)
plt.show()
示例12: write_map_file
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [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()
示例13: plot_cities
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def plot_cities():
path = "/Users/richard/classes/294-1/project/sql/meta_cities.txt"
city_coords = load_city_coords(path)
coords = city_coords.values()
m = Basemap(projection='mill',
llcrnrlon=70. ,llcrnrlat=20,
urcrnrlon=135. ,urcrnrlat=53.)
m.drawcountries()
m.shadedrelief()
unzipped = [list(t) for t in zip(*coords)]
lat, lon = unzipped[0], unzipped[1]
x, y = m(lon, lat)
m.scatter(x,y,s=25)
plt.show()
示例14: draw_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def draw_map(outfilename, dpi, lllat, lllon, urlat, urlon):
enlarge_by = 0.1
plt.figure(num=None, figsize=(48, 48), dpi=dpi, facecolor='w', edgecolor='k')
bmap = Basemap(projection='cyl', resolution='l',
lon_0=0.0,
lat_0=90.0, lat_ts=0.0,
llcrnrlat=lllat,
llcrnrlon=lllon,
urcrnrlat=urlat,
urcrnrlon=urlon)
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)
if outfilename:
plt.savefig(outfilename, dpi='figure')
else:
plt.show()
示例15: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import shadedrelief [as 别名]
def plot(text, size):
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
#from matplotlib.font_manager import FontProperties
#fontP = FontProPerties()
#fontP.set_size('small')
# setup Lambert Conformal basemap.
m = Basemap(width=3000000,height=3000000,projection='lcc',
resolution='c',lat_0=18,lon_0=78)
m.drawcoastlines()
#m.fillcontinents(color='coral',lake_color='aqua')
m.shadedrelief()
colors = numpy.random.rand(30,3)
#lengend
handles = []
for i in range(30):
patch = matpatch.Patch(color = colors[i], label='Topic ' + str(i+1))
handles.append(patch)
plt.legend(handles = handles, bbox_to_anchor=(1.2, 1.0), prop={'size':10})
lat = [17.38,13.08,12.98,19.07,22.57,26.84,26.91,28.63,21.15,22.72,27.16,21.66,26.02,9.92]
lon = [78.49,80.28,77.61,72.88,88.34,80.95,75.78,77.25,79.08,75.86,78.01,83.59,73.85,78.12]
df_x = [0.35,-0.25,-0.35,0.25,0]
df_y = [0.35,0.25,-0.25,-02.5,0]
f_lat = []
f_lon = []
f_size = []
f_color = []
random.seed()
for place_id in range(len(lat)):
for i in range(5):
#f_lat.append(lat[place_id] + df_y[i])
f_lat.append(lat[place_id] + 3*(random.random()-0.5))
f_lon.append(lon[place_id] + 3*(random.random()-0.5))
#f_lon.append(lon[place_id] + df_x[i])
f_size.append(size[place_id][i]*15)
f_color.append(colors[text[place_id][i]])
#m.plot(lon[place_id]+df_y[i],lat[place_id]+ df_x[i], 'bo',markersize = size[place_id][i], latlon = True)
m.scatter(f_lon, f_lat, s = f_size, c = f_color, alpha = 0.5, latlon = True)
m.scatter(lon, lat, s = 8000, c = 'b', alpha = 0.1, latlon = True)
#m.scatter(f_lon, f_lat, s = f_size, c = f_color, latlon = True)
#m.plot(f_lon,f_lat,'bo',markersize = 5, latlon = True)
plt.show()