m = Basemap(projection='robin', lon_0=0, resolution='c')
m.drawmapboundary(fill_color='cornflowerblue')
m.fillcontinents(color='white',lake_color='cornflowerblue', zorder=0)
m.drawcoastlines()
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))
m.readshapefile(r'~/Desktop/ONGOING_PROJEKTS/MISC/PB2/PB2002_plates', name='PB2002_plates', drawbounds=True, color='orange')
#m.bluemarble()
lats = [38.3215, -55.285, -60.274]
lons = [142.36929, -31.877, -46.401]
x, y = m(lons, lats)
focmecs = [[193, 9, 78], [301, 62, 84], [190, 89, -140]]
eq_mw = [9.0, 7.4, 7.7]
ax = plt.gca()
for i in range(len(focmecs)):
# Loop to set the tensor (beach ball) colors
eq = eq_mw[i]
if eq < 6:
beachball_color = 'y'
elif 6 <= eq < 8:
beachball_color = 'orange'
elif 8 <= eq:
beachball_color = 'r'
b = beach(focmecs[i], facecolor=beachball_color, xy=(x[i], y[i]), width=1000000, linewidth=1, alpha=0.85)
b.set_zorder(10)
ax.add_collection(b)
但是对于不同的地图投影,对于不同的区域(本地非全局),地图的背景颜色会发生变化:
m = Basemap(llcrnrlon=west, llcrnrlat=south, urcrnrlon=east, urcrnrlat=north, resolution='h', area_thresh = 0.1, projection='tmerc', lat_ts=0, lon_0=center[0], lat_0=center[1])
# Plot features
m.drawcoastlines()
m.drawcountries()
m.drawstates(color='w')
m.drawrivers(color='lightblue')
m.shadedrelief()
m.drawparallels(np.arange(-81., 81., 2),labels=[1,0,0,0], linewidth=0.0) #-81., 81., 4
m.drawmeridians(np.arange(-180., 181., 4),labels=[0,0,0,1], linewidth=0.0) #-180., 181., 10
m.readshapefile(r'~/Desktop/ONGOING_PROJEKTS/MISC/PB2/PB2002_plates', name='PB2002_plates', drawbounds=True, color='orange')
m.drawmapscale(146.3, 33.2, 145, 40, 500, barstyle='fancy')
目前尚不清楚为什么,但这个橙色边界似乎仍然存在第二个情节的代码,但不是第一个。有谁知道为什么?
答案 0 :(得分:0)
我明白了。而不是:
m.readshapefile(r'~/Desktop/ONGOING_PROJEKTS/MISC/PB2/PB2002_plates', name='PB2002_plates', drawbounds=True, color='orange')
更改为drawbounds=False
通过将其设置为false,您无论如何都可以绘制局部边界。