cartopy:放大到一个区域
cartopy: zoom in to a region
我想使用 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())
然后它产生:
我想要的(放大版):
有办法吗?
您可以使用ax.set_extent()
ax.set_extent([-150, -20, -90, 90])
我想使用 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())
然后它产生:
我想要的(放大版):
有办法吗?
您可以使用ax.set_extent()
ax.set_extent([-150, -20, -90, 90])