我正在尝试使用 python 生成 netcdf 文件的温度颜色图。这是代码的第一部分:
from netCDF4 import Dataset
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
my_path = 'tas_EUR-44_GISS-E2-R_historical_r1i1p3_AUTH-MC-WRF371M_v1_3hr_2005010100-2005123121.nc'
fh = Dataset(my_path, mode='r')
lons = (fh.variables['lon'][:])
lats = (fh.variables['lat'][:])
t = (fh.variables['tas'][:])
t_units = fh.variables['tas'].units
fh.close()
lon_0 = lons.mean()
lat_0 = lats.mean()
m = Basemap(width=5000000, height=3500000,
resolution='l', projection='stere', \
lat_ts=40, lat_0=lat_0, lon_0=lon_0)
cs = m.pcolor(lons, lats, t[0, 0, :, :])
到达此命令行后,会出现以下警告:
/Users/me/anaconda/lib/python3.6/site-packages/mpl_toolkits/basemap/init .py:3677: MatplotlibDeprecationWarning:axes.hold 已弃用。有关更多详细信息,请参阅 API 更改文档 ( http://matplotlib.org/api/api_changes.html )。ax.hold(b)
我也试过包括hold=False,但结果是一样的,你可以在想象中看到:没有contourf。我错过了什么?