博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Using Basemap 1.0.7 in Python 3.6
阅读量:7143 次
发布时间:2019-06-29

本文共 1387 字,大约阅读时间需要 4 分钟。

  hot3.png

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.

转载于:https://my.oschina.net/voole/blog/1831154

你可能感兴趣的文章
Element 2.6.3 发布,基于 Vue 2.0 的桌面端组件库
查看>>
基于kubeadm的kubernetes高可用集群部署
查看>>
定位「数字化助手」,腾讯想用服务创新助力产业智慧升级
查看>>
golang之sync.Mutex互斥锁源码分析
查看>>
SAP增强的PA教材内容
查看>>
C#使用Xamarin开发可移植移动应用(3.Xamarin.Views控件)附源码
查看>>
Java 模拟基于UDP的Socket通信
查看>>
有关 Windows Lite 的一切,只为对抗 Chrome OS?
查看>>
NG-ZORRO 7.0.1 发布,Ant Design 的 Angular 实现
查看>>
scala笔记(三)
查看>>
大数据应用安全研究报告(11家公司实践详解)
查看>>
MES之殇和工业IOT之春
查看>>
阿里云网络漏洞扫描系统AVDS(商业化)发布
查看>>
python splinter 小坑说明
查看>>
控制input输入格式
查看>>
一次XEN启动中的错误捕获
查看>>
esxi嵌套华为Fusioncomputer安装VRM几个关键步骤。
查看>>
DNS设置引起的登录延迟
查看>>
saltstack之SLS文件
查看>>
JAVA构建缓存
查看>>