Home > Net >  Plotting a 43x3 shaped numpy array in 3D
Plotting a 43x3 shaped numpy array in 3D

Time:06-05

I'm trying to plot a 43x3 shaped numpy array. Every row has x, y and z coordinates of a 3D point cloud point. In total there are 43 of them. When I try to plot them with:

plt.plot(arr)
plt.show()

the figure comes out like this:

I wish to plot the "arr" in 3D with each row corresponding to each point. What do you guys think? Thank you.

CodePudding user response:

Try this:

arr = [[0,0,0]] # your array
axes = plt.axes(projection="3d")
 
x = arr[:,0]
y = arr[:, 1]
z = arr[:, 2]

ax.plot3D(x, y, z, 'red')

CodePudding user response:

To draw in 3D you need axes that support it:

fig, ax = plt.subplots(sublot_kw={'projection': '3d'})

You can either plot the data:

ax.plot(*arr.T, ls='none')

Or you can scatter plot it:

ax.scatter(*arr.T)
  • Related