You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to follow the python tutorial to get some basic plots. However, I get traceback below. Also, my code is attached below just in case.
failed to get the current screen resources
Traceback (most recent call last):
File "panel_CO.py", line 47, in <module>
co.plot(ax=ax,cmap=WhGrYlRd)
File "/glade/u/home/lixujin/anaconda3/envs/geoschem/lib/python3.6/site-packages/xarray/plot/plot.py", line 552, in __call__
return plot(self._da, **kwargs)
File "/glade/u/home/lixujin/anaconda3/envs/geoschem/lib/python3.6/site-packages/xarray/plot/plot.py", line 187, in plot
return plotfunc(darray, **kwargs)
File "/glade/u/home/lixujin/anaconda3/envs/geoschem/lib/python3.6/site-packages/xarray/plot/plot.py", line 854, in newplotfunc
**kwargs)
File "/glade/u/home/lixujin/anaconda3/envs/geoschem/lib/python3.6/site-packages/xarray/plot/plot.py", line 1108, in pcolormesh
primitive = ax.pcolormesh(x, y, z, **kwargs)
File "/glade/u/home/lixujin/anaconda3/envs/geoschem/lib/python3.6/site-packages/cartopy/mpl/geoaxes.py", line 1451, in pcolormesh
result = self._pcolormesh_patched(*args, **kwargs)
File "/glade/u/home/lixujin/anaconda3/envs/geoschem/lib/python3.6/site-packages/cartopy/mpl/geoaxes.py", line 1469, in _pcolormesh_patched
if not self._hold:
AttributeError: 'GeoAxesSubplot' object has no attribute '_hold'
Code
# Read data and print out to see the structure# Pay attention to unit conversion# Author: Lixu Jin# Version: GEOS-CHEM 12.2.1, 09/15/2019# import packages#from mpl_toolkits.basemap import Basemapfromgamap_colormapimportWhGrYlRdimportcartopy.crsasccrsimportxbpchimportmatplotlib.pyplotaspltimportxarrayasxrimportnumpyasnpfrommatplotlib.colorsimportLogNormplt.style.use(['seaborn-talk', 'seaborn-ticks'])
#=============================================================# Read single dataset#=============================================================# Read datafiledir='/glade/u/home/lixujin/project/GEOS-CHEM/ExtData/HEMCO/GFAS/v2018-09/2018/'data1='GFAS_201807.nc'data2='GFAS_201808.nc'data3='GFAS_201809.nc'ds1=xr.open_dataset(filedir+data1)
ds2=xr.open_dataset(filedir+data2)
ds3=xr.open_dataset(filedir+data3)
#============================================================# calculation part#============================================================# sum up druing we-can periodco=60*60*24*1e3*(ds1['cofire'].sum('time') +ds2['cofire'].sum('time') +ds3['cofire'].sum('time'))
co.attrs['unit'] ='ppm'print(co)
print(type(co))
# fig setting# empty map.fig=plt.figure(figsize=(8,4))
# without this, it would be super wired.ax=plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
ax.set_title('global CO during wecan period')
co.plot(ax=ax,cmap=WhGrYlRd)
#fig.plot(cmap='gist_stern') # The ax keyword is particularly useful for subplots. Can be omitted here.fig.savefig('co_global1.jpg')
The text was updated successfully, but these errors were encountered:
Bob-thanks. I set up the environment again and it works. I think I found the reason why this AttributeError happens now. After setting up the gcpy environment, I also install the basemap package. And it will automatically downgrade some packages like cartopy and proj4, causing this attributerro eventually.
Lixu
yantosca
changed the title
AttributeError: 'GeoAxesSubplot' object has no attribute '_hold'
[BUG/ISSUE] AttributeError: 'GeoAxesSubplot' object has no attribute '_hold'
Sep 20, 2019
Hi there,
I am trying to follow the python tutorial to get some basic plots. However, I get traceback below. Also, my code is attached below just in case.
Code
The text was updated successfully, but these errors were encountered: