xia*_*012 2 python gis cartopy
我想使用 Cartopy 仅绘制一个区域(在我的情况下,北美和南美)。
我目前正在使用以下代码:
import cartopy
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
lon, lat, freq = .., ..., ... # initialize longitude and latitude and line width
ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(cartopy.feature.COASTLINE)
ax.add_feature(cartopy.feature.BORDERS, linestyle='-', alpha=.5)
for la, lo, fq in zip(lat, lon, freq):
plt.plot(lo, la, color='red', linewidth=fq, marker='o', transform=ccrs.PlateCarree())
Run Code Online (Sandbox Code Playgroud)
然后它产生:
我想要的(放大版):
有没有办法做到这一点?
小智 6
您可以使用ax.set_extent()
ax.set_extent([-150, -20, -90, 90])
Run Code Online (Sandbox Code Playgroud)