本文整理汇总了Python中mpl_toolkits.basemap.Basemap.scatter方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.scatter方法的具体用法?Python Basemap.scatter怎么用?Python Basemap.scatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.scatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_global_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def plot_global_map(self, outputfile=None):
"""
Plot global map of event and stations
"""
# ax = plt.subplot(211)
fig = plt.figure()
ax = plt.gca()
plt.title("Station and Event distribution")
m = Basemap(projection='moll', lon_0=0.0, lat_0=0.0,
resolution='c')
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-90., 120., 30.))
m.drawmeridians(np.arange(0., 420., 60.))
m.drawmapboundary()
cm = plt.cm.get_cmap('RdYlBu')
x, y = m(self.station_loc[:, 1], self.station_loc[:, 0])
m.scatter(x, y, 30, color=self.weight, marker="^", edgecolor="k",
linewidth='0.3', zorder=3, cmap=cm)
plt.colorbar(shrink=0.8)
cmt_lat = self.event.latitude
cmt_lon = self.event.longitude
src_x, src_y = m(cmt_lon, cmt_lat)
m.scatter(src_x, src_y, 60, color="g", marker="o", edgecolor="k",
linewidth='0.3', zorder=3)
if outputfile is None:
plt.show()
else:
plt.savefig(outputfile)
plt.close(fig)
示例2: WorkBook_plotPrisons
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def WorkBook_plotPrisons(self, coords):
lons = coords[0]
lats = coords[1]
print("Graphing image...")
m = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64,
urcrnrlat=49, projection='lcc', lat_1=33, lat_2=45,
lon_0=-95, resolution='h', area_thresh=10000)
x, y = m(lons, lats)
m.drawmapboundary(fill_color='white')
m.fillcontinents(color='white',lake_color='white')
m.scatter(x,y,10,marker='D',color='m')
plt.figure(frameon=False)
plt.title('US Prison Locations',fontsize=12)
plt.savefig("USPrisons.png")
background = Image.open("SocioEconomicBackground.png")
overlay = Image.open("USPrisons.png")
background = background.convert("RGBA")
overlay = overlay.convert("RGBA")
new_img = Image.blend(background, overlay, 0.5)
new_img.save("SocioEconomic_Prison.png","PNG")
示例3: Map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def Map(self):
m = Basemap(projection='cyl', # stere, tmerc, lcc
lat_0=39.828127, lon_0=-98.579404,
urcrnrlon=-62.208289, urcrnrlat=51.342619,
llcrnrlon=-128.936426, llcrnrlat=19.06875)
m.drawcoastlines() # draw coastlines
m.drawmapboundary() # draw a line around the map region
m.drawparallels(np.arange(-90., 120., 30.), labels=[1, 0, 0, 0]) # draw parallels
m.drawmeridians(np.arange(0., 420., 60.), labels=[0, 0, 0, 1]) # draw meridians
m.drawstates()
m.drawcountries()
lon = list()
lon.append(-80.633333)
lon.append(-74.364684)
lon.append(-75.387778)
lon.append(-84.253333)
lat = list()
lat.append(28.116667)
lat.append(40.715622)
lat.append(40.043889)
lat.append(30.455)
m.scatter(lon, lat, latlon=True, c=np.random.rand(3))
#m.pcolor(lon, lat, latlon=True)
plt.title('United States Fair Market Rent') # add a title
plt.show()
示例4: plot_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def plot_map(lons, lats, c, legend_label, projection='mill',
llcrnrlat=-80, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180, resolution='i'):
''' Optional Arguments: projection - map projection, default set as 'mill'
llcrnrlat - lower left corner latitude value, default is -80
urcrnrlat - upper right corner latitude value, default is 90
llcrnrlon - lower left corner longitude value, default is -180
urcrnrlon - upper right corner longitude value, default is 180
resolution - the resolution of the plot, default is 'i'
Required Arguments: lons - list of longitude values to be plotted
lats - list of latitude values to be plotted
c - the color of the points to be plotted
legend_label - how this set of points will be labeled on the legend
Returns: m - a basemap object defined by input bounds with input points included '''
# Creates a basic plot of a series of lat,lon points over a defined region
m = Basemap(projection=projection, llcrnrlat=llcrnrlat, urcrnrlat=urcrnrlat,
llcrnrlon=llcrnrlon, urcrnrlon=urcrnrlon, resolution=resolution)
m.drawcoastlines()
m.drawmapboundary()
m.drawcountries()
m.etopo()
m.drawmeridians(np.arange(llcrnrlon, urcrnrlon, 5), labels=[0,0,0,1], fontsize=10)
m.drawparallels(np.arange(llcrnrlat, urcrnrlat, 5), labels=[1,0,0,0], fontsize=10)
x,y = m(lons, lats)
m.scatter(x, y, color=c, label=legend_label, marker='o', edgecolor='none', s=10)
return m
示例5: generate_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def generate_map(output, latlng, wesn=None):
"""
Using Basemap and the matplotlib toolkit, this function generates a map and
puts a red dot at the location of every IP addresses found in the list.
The map is then saved in the file specified in `output`.
"""
print("Generating map and saving it to {}".format(output))
lats=[]
lngs=[]
for i in latlng:
if i[1]:
lats.append(i[1])
lngs.append(i[2])
if wesn:
wesn = [float(i) for i in wesn.split('/')]
m = Basemap(projection='cyl', resolution='l',
llcrnrlon=wesn[0], llcrnrlat=wesn[2],
urcrnrlon=wesn[1], urcrnrlat=wesn[3])
else:
m = Basemap(projection='cyl', resolution='l')
m.bluemarble()
x, y = m(lngs, lats)
m.scatter(x, y, s=1, color='#ff0000', marker='o', alpha=0.3)
plt.savefig(output, dpi=300, bbox_inches='tight')
示例6: example_2
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def example_2():
# retrieve data
dir = "/homespace/gaubert/viirs/Mband-SDR"
geo_file = h5py.File("%s/%s" %(dir,"GMODO_npp_d20030125_t0847056_e0848301_b00015_c20090513182937526121_gisf_pop.h5"))
lats = geo_file['All_Data']['VIIRS-MOD-GEO_All']['Latitude'][:]
lons = geo_file['All_Data']['VIIRS-MOD-GEO_All']['Longitude'][:]
# draw map with markers for float locations
#m = Basemap(projection='hammer',lon_0=180)
lon_ref = lons[0][0]-lons[-1][-1]/2
lat_ref = 10
#m = Basemap(projection='ortho',lat_0=lat_ref,lon_0=lon_ref,resolution='l')
m = Basemap(projection='nsper',lat_0=lat_ref,lon_0=lon_ref,satellite_height=2000*1000,resolution='l')
#x, y = m(lons[0:10],lats[0:10])
x,y = m(lons,lats)
#m.drawcoastlines()
m.drawmapboundary(fill_color='#99ffff')
m.fillcontinents(color='#cc9966',lake_color='#99ffff')
m.scatter(x,y,s = 1 ,color='k')
#m.drawgreatcircle(lons[0][0],lats[0][0],lons[0][-1],lats[0][-1],linewidth=2,color='b')
#m.drawgreatcircle(lons[-1][0],lats[0][0],lons[-1][-1],lats[0][-1],linewidth=2,color='b')
plt.title('Locations of %s ARGO floats active between %s and %s' %\
(len(lats),'2002', '2003'))
plt.savefig('/tmp/plotargo.png')
示例7: show
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def show(self, proj='moll', lon_0=180, tmap=None, coord=None):
from mpl_toolkits.basemap import Basemap
import pylab as plt
import resources.figures as figures
figures.set_fancy()
if coord==None:
ra = np.rad2deg(self.grid['points'][:,0])
dec = np.rad2deg(self.grid['points'][:,1])
else:
ra = np.rad2deg(coord[:,0])
dec = np.rad2deg(coord[:,1])
fig = plt.figure()
m = Basemap(projection=proj,lon_0=lon_0)#,celestial=True) # celestial=True inverses alpha (East towards the right)
m.drawparallels(np.arange(-60.,90.,30.),labels=[1,0,0,0])
m.drawmeridians(np.arange(0.,360.,30.))
ra__ = np.arange(0., 360., 30.)
x, y = m(ra__,ra__*0)
for x,y,t in zip(x,y,ra__):
plt.text(x, y, figures.format_degree(t), color='black', ha='center', weight='black', size='small') ##93c6ed
if tmap==None:
m.scatter(ra,dec,latlon=True,marker='x',s=20,cmap=plt.cm.binary)
else:
m.scatter(ra,dec,c=tmap,latlon=True,marker='x',s=20,cmap=plt.cm.binary)
plt.show()
示例8: triangulation_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def triangulation_map(station_lon, station_lat, station_val, cmap=None, *args, **kwargs):
""" Using matplotlib.pyplot.tricontourf() function to plot contourplot on an irreguar grid by using triangulation. """
# map boundries
lat_0 = 51
lat_min = 47
lat_max = 55
lon_0 = 10
lon_min = 5
lon_max = 16
m = Basemap(projection='tmerc', lat_0=lat_0, lon_0=lon_0,
llcrnrlat=lat_min, llcrnrlon=lon_min, urcrnrlat=lat_max,
urcrnrlon=lon_max, resolution='i')
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary()
m.contourf(station_lon, station_lat, station_val, cmap=cmap, latlon=True, tri=True, *args, **kwargs)
m.scatter(station_lon, station_lat, color='k', s=5, latlon=True)
# Set Triangulation manual?:
#station_x, station_y = m(station_lon, station_lat)
#triang = tri.Triangulation(station_x, station_y)
#plt.tricontour(station_x, station_y, station_val, 15, linewidths=0.5, colors='k')
#plt.tricontourf(x, y, z, 15, cmap=plt.cm.rainbow, norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max()))
plt.show()
示例9: address_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def address_map( data ) :
a = addresses_with_locations( data )
plt.figure()
m = Basemap( projection = "robin",
llcrnrlon = -180,
llcrnrlat = -80,
urcrnrlon = 180,
urcrnrlat = 80,
lon_0 = 0,
lat_0 = 0,
resolution = "c" )
m.drawcoastlines()
m.fillcontinents( color = 'coral', lake_color = 'aqua', alpha=0.3 )
m.drawmeridians( arange( -180, 180, 60 ) )
m.drawparallels( arange( -80, 80, 60 ) )
xys = array([m(x[2][1], x[2][0]) for x in a])
xs = xys[:,0]
ys = xys[:,1]
counts = array([x[1] for x in a]) * 200
m.scatter( xs, ys, s=counts, marker='o', c='b', alpha=0.3 )
plt.title("Research by sites, top 500 papers Ultraintense Lasers")
plt.savefig("map.png")
plt.close()
示例10: run
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def run(FILE_NAME):
with h5py.File(FILE_NAME, mode="r") as f:
name = "/RetrievalResults/xco2"
data = f[name][:]
units = f[name].attrs["Units"][0]
longname = f[name].attrs["Description"][0]
# Get the geolocation data
latitude = f["/RetrievalGeometry/retrieval_latitude"][:]
longitude = f["/RetrievalGeometry/retrieval_longitude"][:]
m = Basemap(projection="cyl", resolution="l", llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180)
m.drawcoastlines(linewidth=0.5)
m.drawparallels(np.arange(-90, 91, 45))
m.drawmeridians(np.arange(-180, 180, 45), labels=[True, False, False, True])
m.scatter(longitude, latitude, c=data, s=1, cmap=plt.cm.jet, edgecolors=None, linewidth=0)
# cb = m.colorbar(orientation='horizontal', format='%.1e')
cb = m.colorbar(location="bottom", format="%.1e", pad="10%")
cb.set_label(units)
basename = os.path.basename(FILE_NAME)
plt.title("{0}\n{1}".format(basename, longname))
fig = plt.gcf()
# plt.show()
pngfile = "{0}.py.png".format(basename)
fig.savefig(pngfile)
示例11: draw_point
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def draw_point(lats, lons):
m = Basemap(resolution='i')
m.drawcoastlines()
m.drawcountries()
x, y = m(lons, lats)
m.scatter(x, y, s=0.3, color='#ff0000', marker='.')
plt.show()
示例12: Plotcat
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def Plotcat(ra_0, dec_0, fov_size=15., grid_size=2., allsky=False):
pkscat = np.loadtxt('source_list_pks_140MHz',usecols=(0,1))
pkscat[:,0] *= 15.
sky = Basemap(projection='ortho', lon_0=-ra_0, lat_0=dec_0, celestial=True)
if allsky==True:
sky.drawmeridians(np.arange(0.,360.,grid_size))
sky.drawparallels(np.arange(90,-90,-grid_size))
sky.drawmapboundary(fill_color='White')
catx, caty = sky(pkscat[:,0],pkscat[:,1])
sky.scatter(catx,caty,3,marker='o',color='Black')
else:
cnreq = np.array([[ra_0+fov_size/2., dec_0-fov_size/2.],
[ra_0-fov_size/2., dec_0+fov_size/2.]])
# = [[ll_ra, ll_dec], [ur_ra, ur_dec]]
cnrxy = np.transpose(np.array(sky(cnreq[:,0],cnreq[:,1])))
# = [[ll_x, ll_y], [ur_x, ur_y]]
cenxy = np.array(sky(ra_0,dec_0))
cnrmap = cnrxy-np.array([cenxy,cenxy])
m = Basemap(projection='ortho', lon_0=-ra_0, lat_0=dec_0,
celestial=True, llcrnrx=cnrxy[0,0]-cenxy[0],
llcrnry=cnrxy[0,1]-cenxy[1], urcrnrx=cnrxy[1,0]-cenxy[0],
urcrnry=cnrxy[1,1]-cenxy[1])
m.drawmeridians(np.arange(cnreq[0,0], cnreq[1,0], -grid_size),
labels=[0,0,0,1],fmt=format_label)
m.drawparallels(np.arange(cnreq[0,1], cnreq[1,1], grid_size),
labels=[1,0,0,0])
m.drawmapboundary(fill_color='White')
catx, caty = m(pkscat[:,0],pkscat[:,1])
m.scatter(catx,caty,3,marker='o',color='Black')
示例13: plot_cities
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def plot_cities():
map = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64,
urcrnrlat=49, projection='lcc', lat_1=33, lat_2=45,
lon_0=-95, resolution='i', area_thresh=10000)
map.drawcoastlines()
map.drawcountries()
map.drawstates()
# key is language, value is pair (longitudes, latitudes)
plots = { "Java" : ([], []), "Python" : ([], []), "R" : ([], []) }
# we want each language to have a different marker and color
markers = { "Java" : "o", "Python" : "s", "R" : "^" }
colors = { "Java" : "r", "Python" : "b", "R" : "g" }
for (longitude, latitude), language in cities:
plots[language][0].append(longitude)
plots[language][1].append(latitude)
# create a scatter series for each language
for language, (x, y) in plots.iteritems():
x1, y1 = map(x, y)
map.scatter(x1, y1, color=colors[language], marker=markers[language],
label=language, zorder=10)
# plot_state_borders(plt) # assume we have a function that does this
plt.legend(loc=3,prop={'size':12}) # let matplotlib choose the location
plt.title("Favorite Programming Languages")
plt.show()
示例14: run
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def run(FILE_NAME):
with h5py.File(FILE_NAME, mode="r") as f:
name = "/S1/surfacePrecipitation"
data = f[name][:]
units = f[name].attrs["Units"]
# The attribute says -9999.900391 but data uses -9999.0.
# _FillValue = f[name].attrs['CodeMissingValue']
_FillValue = -9999.0
data[data == _FillValue] = np.nan
data = np.ma.masked_where(np.isnan(data), data)
# Get the geolocation data
latitude = f["/S1/Latitude"][:]
longitude = f["/S1/Longitude"][:]
m = Basemap(projection="cyl", resolution="l", llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180)
m.drawcoastlines(linewidth=0.5)
m.drawparallels(np.arange(-90, 91, 45))
m.drawmeridians(np.arange(-180, 180, 45), labels=[True, False, False, True])
m.scatter(longitude, latitude, c=data, s=1, cmap=plt.cm.jet, edgecolors=None, linewidth=0)
cb = m.colorbar(location="bottom", pad="10%")
cb.set_label(units)
basename = os.path.basename(FILE_NAME)
plt.title("{0}\n{1}".format(basename, name))
fig = plt.gcf()
# plt.show()
pngfile = "{0}.py.png".format(basename)
fig.savefig(pngfile)
开发者ID:hdfeos,项目名称:zoo_python,代码行数:33,代码来源:2A.GPM.GMI.GPROF2014v1-4.20150331-S232954-E010226.006182.V03D.HDF5.py
示例15: render_nextbus_dataframe
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import scatter [as 别名]
def render_nextbus_dataframe(route, nextbus_df):
"""Plots the NextBus Vehicle Location's Panda Data frame to a
Matplotlib and Basemap Geospatial image."""
min_long = min(nextbus_df.lon)
min_lat = min(nextbus_df.lat)
max_long = max(nextbus_df.lon)
max_lat = max(nextbus_df.lat)
bmap = Basemap(llcrnrlon=min_long, llcrnrlat=min_lat,
urcrnrlon=max_long, urcrnrlat=max_lat,
ellps='WGS84',
resolution='h', area_thresh=1000)
bmap.drawmapboundary(fill_color='white')
bmap.scatter(nextbus_df.lon, nextbus_df.lat,
marker='d', edgecolor='g', facecolor='g', alpha=0.5)
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.axis([min_long, max_long, min_lat, max_lat])
plt.title('NextBus Vehicle Locations for route {}'.format(route))
plt.grid(True)
# plt.legend(loc='lower center')
plt.savefig('nextbus_vehicle_locations.png', fmt='png', dpi=600)
# plt.show()
# Other components (like GMaps plotting) will also use Matplotlib, so
# it's better to clear the figure that Matplotlib generated
plt.clf()
开发者ID:je-nunez,项目名称:NextBus_real_time_Route_Bus_locations_to_Pandas_Dataframe,代码行数:31,代码来源:plot_dataframe_nextbus_vehicle_locations.py