I often come across the situation where I have some 3d numpy array like: data = np.random.rand(10, 10, 10).
Is there any way I can scatter data using their (x,y,z) projectories. for example: data(1,1,4) = 514, and make a 3D plot which plots point(1,1,4) as the color data cdata corresponding to the value 514.
What is the pythonic way to go from data to x, y, z and cdata?
Now, you won't be able to see inside of the shape.
Note that voxels are more commonly used to show/exclude boxes rather than to show data as the color, so the ones_like is just saying "show every box" and the facecolors kwarg is calling the colormap directly to get color information in a format voxels can use.
Norm just normalizes the data to a range of 0 to 1, if you really only care about np.random.rand data, then that may be omitted, as that is already in that range.
Be aware that most of the boxes will not be visible, only those on the surface will be.
Activity
ksunden commented on Oct 26, 2022
I think this does what you want:

(I changed shapes just to make it obvious that order does matter when the shapes are not equal)
Firestar-Reimu commented on Oct 27, 2022
Thanks! This solve my problem.
If we can plot them like boxes will be better.
for example, in the graph above, every plot is a 1x1x1 box with the same color?
ksunden commented on Oct 27, 2022
Ah, then this sounds like voxels
(with the same setup for axes with 3d projection)
Now, you won't be able to see inside of the shape.
Note that voxels are more commonly used to show/exclude boxes rather than to show data as the color, so the ones_like is just saying "show every box" and the facecolors kwarg is calling the colormap directly to get color information in a format voxels can use.
Norm just normalizes the data to a range of 0 to 1, if you really only care about np.random.rand data, then that may be omitted, as that is already in that range.
Be aware that most of the boxes will not be visible, only those on the surface will be.
scottshambaugh commented on Nov 1, 2022
Closing since a pythonic solution was provided.