1
これは私がmatplotlibを使用してプロットする最初の試みです。私はmatplotlibを使ってジオポテンシャルの高さのnetCDFファイルデータをプロットしようとしていますが、空のイメージがあります。海岸線などはありません。ただ空白の画面。 私のデータは5 Nから40 N、65 Eから100 Eの範囲です。matplotlibを使用してデータを表示できません
私はlat、lon、hgtの値を表示していますが、これらはすべて有効です。ここで
私のコードです -
nc_f = './hgt_500_2014_12_5_00Z.nc' # Your filename
nc_fid = Dataset(nc_f, 'r') # Dataset is the class behavior to open the file
lats = nc_fid.variables['lat'][:]
lons = nc_fid.variables['lon'][:]
time = nc_fid.variables['time'][:]
hgt = nc_fid.variables['hgt'][:]
hgt_units = nc_fid.variables['hgt'].units
nc_fid.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)
lon, lat = np.meshgrid(lons, lats)
xi, yi = m(lon, lat)
cs = m.pcolor(xi,yi,np.squeeze(hgt))
m.drawparallels(np.arange(5., 40., 5.), labels=[1,0,0,0], fontsize=10)
m.drawmeridians(np.arange(65., 100., 5.), labels=[0,0,0,1], fontsize=10)
m.drawcoastlines()
m.drawstates()
m.drawcountries()
cbar = m.colorbar(cs, location='bottom', pad="10%")
cbar.set_label(hgt_units)
plt.title('Geopotential Height')
plt.show()
私も私のpython
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py", line 69, in on_draw_event
buf, cairo.FORMAT_ARGB32, width, height)
NotImplementedError: Surface.create_for_data: Not Implemented yet.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/matplotlib-1.5.0-py3.4-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py", line 69, in on_draw_event
buf, cairo.FORMAT_ARGB32, width, height)
NotImplementedError: Surface.create_for_data: Not Implemented yet.
100%の右側に問題がある可能性があり
import matplotlib
matplotlib.use('Agg')
:TkAgg、WX、QTAgg、QT4Aggは次のように!私はちょうどカイロをインストールし、それを働かせた!どうもありがとう ! – gansub