小编Xab*_*ade的帖子

如何修复“ TypeError:未调整大小的对象的len()”

我正进入(状态:

TypeError:len()个未调整大小的对象

运行以下脚本后:

from numpy import *

v=array(input('Introduce un vector v: '))
u=array(input('Introduce un vector u: '))

nv= len(v)
nu= len(u)

diferenza= 0; i=0

if nv==nu:

    while i<nv:
        diferenza=diferenza + ((v[i+1]-u[i+1]))**2

    modulo= sqrt(diferenza)
    print('Distancia', v)
else:
    print('Vectores de diferente dimensión')
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

python arrays numpy

7
推荐指数
1
解决办法
2万
查看次数

更改颜色范围 3d 图 Matplotlib

我正在尝试制作 3D 绘图,但颜色范围太小,仅覆盖 z 轴可以具有的值的一小部分。我该如何解决?

我附上代码和我得到的图像:

fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(B , ENERGY, result_plot, cmap=cm.Spectral_r , linewidth=0.0 ,antialiased =False)

colorbar( surf, shrink=0.5, aspect=3)


ax.view_init(30, 45)
plt.show()
Run Code Online (Sandbox Code Playgroud)

3d 绘图

python 3d plot matplotlib surface

4
推荐指数
1
解决办法
6914
查看次数

标签 统计

python ×2

3d ×1

arrays ×1

matplotlib ×1

numpy ×1

plot ×1

surface ×1