I have been attempting several methods to plot a 3D diagram of a n by n boolean array in Mathematica but none of them produced satisfactory result. I want the $3D$ plot to have a cube when M[i,j,k] == 1
and when M[i,j,k] == 0
just leaves as blank. Below is the best result I got.
L=10
M = RandomReal[{0, 1}, {L, L, L}];
For[k = 1, k <= L, k++,
For[j = 1, j <= L, j++,
For[i = 1, i <= L, i++,
If[M[[i, j, k]] < 0.5,
M[[i, j, k]] = 1,
M[[i, j, k]] = 0
]]]];
Image3D[M, ImageSize -> 500, Boxed -> True]
The Image3D
function gives a very fluffy and opaque look on the cubes which I couldn't change!!
Is there someway I can change the opacity and color of the Image3D
function in this case? Or is there a better way to plot this matrix?
Comments
Post a Comment