Python Cartopy set_区段不工作

Python Cartopy set_区段不工作,python,python-2.7,matplotlib,cartopy,Python,Python 2.7,Matplotlib,Cartopy,我正在尝试使用Mateplotlib cartopy制作下面的绘图。这是我正在使用的代码 import cartopy.crs as ccrs fig=plt.figure(figsize=(15,11)) ax = plt.subplot(111, projection=ccrs.PlateCarree(central_longitude=0)) mm = ax.contourf(new_lon[:],lat_post,new_aa[0,:,:],transform=ccrs.Plate

我正在尝试使用Mateplotlib cartopy制作下面的绘图。这是我正在使用的代码

import cartopy.crs as ccrs

fig=plt.figure(figsize=(15,11))
ax = plt.subplot(111, projection=ccrs.PlateCarree(central_longitude=0))
mm =   ax.contourf(new_lon[:],lat_post,new_aa[0,:,:],transform=ccrs.PlateCarree(central_longitude=0))

ax.coastlines(resolution='10m');
ax.stock_img();
# the following two lines increaes the vertical distance between the title and the upper tick.
from matplotlib import rcParams
rcParams['axes.titlepad']=20
# drawing the longitude and latitude ticks.
gl = ax.gridlines(crs=ccrs.PlateCarree(central_longitude=0), draw_labels=True,linewidth=2, color='gray', alpha=0.5, linestyle='--')
然而,一旦我添加了以下代码集
ax.set\u范围([np.min(新长度)、np.max(新长度)、np.min(横向立柱)
,np.max(lat_post)])

数字是这样的

看你原来的地图,它看起来像是在0经度有一条缝,所以我猜
np.min(新的)是0,
np.min(新的)是360。如果将其与
set_extent()
一起使用,则在本初子午线处会得到一条非常窄的条纹。我想如果你做
设置范围([-180,180,np.min(lat\u post),np.max(lat\u post)]
它会工作得更好

在这种情况下,我能想到的以编程方式实现它的唯一方法是:

lon_bounds = new_lon[:]  # copy
lon_bounds[lon_bounds > 180] -= 360
ax.set_extent([np.min(lon_bounds), np.max(lon_bounds), np.min(lat_post), np.max(lat_post)])

非常感谢。
设置范围([-180180,np.min(lat_post),np.max(lat_post)]
解决了这个问题。另一方面,上一个代码给了我一个扭曲的形状。正如您所期望的,新的长度从0开始,在358.40955结束。我想知道为什么当长度从0开始,在360结束时,设置范围会有问题。问题是,当您将范围设置为0和360时,当它将这些值转换为p另一种选择,如果你知道你总是想显示整个地球,你也可以这样做:
ax.set\u global()
非常感谢。明白了。