I am trying to plot a 3D-Array in matplotlib, but I only see a linear output. The expected output was a 10x10x10 cube.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
points = np.zeros((10, 10, 10))
for x in range(10):
for y in range(10):
for z in range(10):
points[x][y][z] = z
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(points[:,0],points[:,1],points[:,2])
plt.show()


points[:,0]andpoints[:,1]andpoints[:,2]? Those are the planes you are passing in as the x points, the y points, and the z points, and those planes are all identical. It's going to plot the points by picking one from each in corresponding positions. Since the planes are identical, it will plot [n,n,n] for n between 0 and 9. If you were trying to plot 1000 different points in a 10x10x10 grid, I'll post an answer that does that.