I'm creating a filled contour plot using m.contourf() form basemap(). For some reason ever since I upgraded to Python 3.6 and upgraded my packages numpy, scipy pandas etc, I keep getting this error. It worked fine in Python2.7 though.
Error,
Traceback (most recent call last): File "", line 1, in File "/Users/karthik/Documents/code/test_countourf.py", line 99, in map.contourf(x, y, _arr, zorder = 0, cmap = _cmap, norm = cNorm, levels=levels) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py", line 521, in with_transform return plotfunc(self,x,y,data,*args,**kwargs) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py", line 3644, in contourf xx = x[x.shape[0]/2,:]IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
My suspicion was that x.shape[0]/2 gives a float(since Python 3 I think) instead of an integer which might be the error since I didn't see the error in Python 2.7.
Any ideas on how to fix it in Python 3.6?
Thanks!
You could replace x.shape[0]/2
by x.shape[0]//2
as a quick fix, . In general, you may need to update matplotlib as well as basemap.