-
Notifications
You must be signed in to change notification settings - Fork 397
Closed
matplotlib/matplotlib
#12670Description
Bug report
Bug summary
Basemap cannot work when I update the matplotlib to the new version 3.0.1.
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
outfile = r'E:\wrong.tif'
# read in data on lat/lon grid.
# data from https://github.com/matplotlib/basemap/tree/master/examples
hgt = np.loadtxt(r'E:\tmp\basemap\500hgtdata.gz')
lons = np.loadtxt(r'E:\tmp\basemap\500hgtlons.gz')
lats = np.loadtxt(r'E:\tmp\basemap\500hgtlats.gz')
lons, lats = np.meshgrid(lons, lats)
mnh = Basemap(lon_0=-105, boundinglat=20.,
resolution='c', area_thresh=10000., projection='nplaea')
xnh, ynh = mnh(lons, lats)
CS = mnh.contour(xnh, ynh, hgt, 15, linewidths=0.5, colors='k')
CS = mnh.contourf(xnh, ynh, hgt, 15, cmap=plt.cm.Spectral)
mnh.drawcoastlines(linewidth=0.5)
delat = 30.
circles = np.arange(0., 90., delat).tolist() + \
np.arange(-delat, -90, -delat).tolist()
mnh.drawparallels(circles, labels=[1, 0, 0, 0])
delon = 45.
meridians = np.arange(0, 360, delon)
mnh.drawmeridians(meridians, labels=[1, 0, 0, 1])
plt.title('NH 500 hPa Height (cm.Spectral)')
# colorbar on bottom.
mnh.colorbar(pad='5%')
plt.savefig(outfile, dpi=300, bbox_inches='tight')
plt.show()
Actual outcome
# If applicable, paste the console output here
Traceback (most recent call last):
File "E:/MyWork/code/python/psta/tmp.py", line 20, in <module>
CS = mnh.contour(xnh, ynh, hgt, 15, linewidths=0.5, colors='k')
File "D:\Python36\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 542, in with_transform
return plotfunc(self,x,y,data,*args,**kwargs)
File "D:\Python36\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 3566, in contour
self._restore_hold(ax)
File "D:\Python36\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 3229, in _restore_hold
ax._hold = self._tmp_hold
AttributeError: can't set attribute
Expected outcome
Matplotlib version
- Operating system: Windows 10 x64
- Matplotlib version: 3.0.1
- Matplotlib backend (
print(matplotlib.get_backend())
): module://backend_interagg - Python version: 3.6.6
- Jupyter version (if applicable): None
- basemap version: 1.2.0
- PyCharm version: 2018.2.4
I install matplotlib and basemap from https://www.lfd.uci.edu/~gohlke/pythonlibs.
adrianodennanni, aamanushin and hxd1011
Metadata
Metadata
Assignees
Labels
No labels