Engine
Engine

Reputation: 5422

plotting data in python from 2D to 3D

I have a bunch of data that I need to see in some understandable manner. here what I've done so far:

..................................
features = []
for i in range(len(variance_list[0][:])):
    for j in range(len(variance_list)):
         features.append(variance_list[j][i])

    plt.plot(features)
    features.clear()
plt.xlabel('classes ')
plt.ylabel('features')
plt.show()

The result looks as followed:

enter image description here

So I've tried to plot this in 3D as followed :

for i in range(len(variance_list[0][:])):
    for j in range(len(variance_list)):
         Axes3D.plot(i,j,variance_list[j][i],label='parametric curve')
plt.show()

I get the following error message:

       1510         #        many other traditional positional arguments occur
   1511         #        such as the color, linestyle and/or marker.
-> 1512         had_data = self.has_data()
   1513         zs = kwargs.pop('zs', 0)
   1514         zdir = kwargs.pop('zdir', 'z')

AttributeError: 'int' object has no attribute 'has_data'

Any idea what I'm missing, or how may I solve this

Upvotes: 1

Views: 98

Answers (2)

f5r5e5d
f5r5e5d

Reputation: 3706

in addition to cosmos' suggestion, there is a difference in x,y lines and the z var

variance_list=[[np.random.rand()**2*(j+1) for _ in range(10)] for j in range(4)]

fig = plt.figure()
ax = fig.gca(projection='3d')
for j in range(len(variance_list)):
    ax.plot(range(len(variance_list[0])),variance_list[j],j,label='parametric curve')
plt.show()

enter image description here

Upvotes: 1

cosmosa
cosmosa

Reputation: 761

instead of Axes3D.plot it should be:

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(...)

according to mplot3d docs

Upvotes: 0

Related Questions