Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Axes3D

I got a problem with my Axes3D plotter, every time I put somethign in I get TypeError: unbound method scatter() must be called with Axes3D instance as first argument (got list instance instead)

And I don't quite understand what kind of type it wants from me, as I just want to put the x,y,z coordinates of a single point in. (these can be lists or ints, both give errors.)

Axes3D.scatter( Xc[l], Yc[l], Zc[l], c=(i/nbodies,i/nbodies,i/nbodies))

I really have no idea what the problem is here

like image 984
Coolcrab Avatar asked Dec 20 '22 05:12

Coolcrab


1 Answers

You have to instantiate the axis first:

ax = Axes3D(plt.gcf())
ax.scatter( Xc[l], Yc[l], Zc[l], c=(i/nbodies,i/nbodies,i/nbodies))

Alternatively, you may use

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter( Xc[l], Yc[l], Zc[l], c=(i/nbodies,i/nbodies,i/nbodies))
like image 65
David Zwicker Avatar answered Jan 30 '23 13:01

David Zwicker