源码

首页 » 归档 » 源码 » TypeError:在绘图时,只有length-1数组可以转换…

TypeError:在绘图时,只有length-1数组可以转换…


我有这样的Python代码:

import numpy as np
import matplotlib.pyplot as plt

def f(x):
    return np.int(x)

x = np.arange(1, 15.1, 0.1)
plt.plot(x, f(x))
plt.show()

而这样的错误:

TypeError: only length-1 arrays can be converted to Python scalars

我该如何解决?

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/typeerrorzaihuitushizhiyoulength-1shuzukeyizhuanhuan.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 23, 2019 at 01:18 下午

热评文章