绘图温度中存在卡托问题

问题描述 投票:0回答:1

我有带有以下信息的xarray数据集:

Coordinates:
lat: 192
lon: 288
time: 1200(monthly data)

Data Variables:
temp (time, lat, lon): 

现在,我想为特定日期绘制带有海岸线和颜色条的zg。我正在使用以下代码:

lats = monthly_mean.variables['lat'][:]
lons = monthly_mean.variables['lon'][:]
temp = monthly_mean.variables['temp'][0, :, :]

ax = plt.axes(projection=ccrs.PlateCarree())

plt.contourf(lons, lats, temp, 60,
             transform=ccrs.PlateCarree())

ax.coastlines()

plt.show()

我不知道我在做什么错,每当运行此代码时,我的colab服务器在运行第6行(plt.contourf())时就会崩溃。有人可以告诉我我做错了什么吗,还是有其他方法可以用海岸线和底图来绘制海岸线图。

python matplotlib matplotlib-basemap python-xarray cartopy
1个回答
0
投票

您也可以尝试使用da.plot()方法:这里有一些文档(http://xarray.pydata.org/en/stable/plotting.html)。

在您的情况下,我建议类似:

temp=monthly_mean['temp']

ax = plt.axes(projection=ccrs.PlateCarree())

temp[0,:,:].plot(ax=ax, transform=ccrs.PlateCarree())

ax.coastlines()
© www.soinside.com 2019 - 2024. All rights reserved.