Je suis en train de créer un terrain 3D et le code que j'ai écrit est:tracé 3D avec python numpy
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
a=[1,5,10]
x=list(range(1,10))
y=list(range(1,10))
z=list(range(1,10))
for i in np.arange(1,9,1):
r1=a[2]*y[i]-a[1]*z[i]
r2=a[0]*z[i]-a[2]*x[i]
r3=a[1]*x[i]-a[0]*y[i]
ax.plot(r1,r2,r3)
Pour cela, j'obtiens l'erreur:
TypeError Traceback (most recent call
last)
<ipython-input-95-dd97076f2b6e> in <module>()
14 r2=a[0]*z[i]-a[2]*x[i]
15 r3=a[1]*x[i]-a[0]*y[i]
---> 16 ax.plot(r1,r2,r3)
1537 # Match length
1538 if not cbook.iterable(zs):
-> 1539 zs = np.ones(len(xs)) * zs
1540
1541 lines = Axes.plot(self, xs, ys, *args[argsi:],
**kwargs)
TypeError: object of type 'int' has no len()
Il ressemble à quelque chose est mal avec la commande plot, mais je ne peux pas le localiser. Toute aide est appréciée.