简体   繁体   中英

cartopy: zoom in to a region

I would like to use Cartopy to plot only a region (in my case, North and South America).

I am currently using the following code:

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())

Then it produces:

在此输入图像描述

What I want (zoomed-in version):

在此输入图像描述

Is there anyway to do this?

你可以使用ax.set_extent()

ax.set_extent([-150, -20, -90, 90])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM