From: jongren on
Hi,

I have a 3D matrix, of the form
{{{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10,11,12},
{13,14,15,16}},
{{17, 18, 19, 20},
{21, 22, 23, 24},
{25, 26, 27, 28},
{29, 30, 31, 32}}}

I want to plot this matrix, where every number is a unit cube, to give a sort of 3D grid, where the number gives the colour. In reality most numbers would be 0, which would be transparent.

I want to do this as I'm developing a 3D partitioned cellular automaton, and have it defined over structures of this sort, and I want to be able to visualise its development. In 2D I've used MatrixPlot and Animate to do this.

One layer is 1-16, and the second is 17-32.

Any help would be greatly appreciated,

Thanks!

From: M.Roellig on
On 27 Apr., 10:03, jongren <jongreno...(a)gmail.com> wrote:
> Hi,
>
> I have a 3D matrix, of the form
> {{{1, 2, 3, 4},
> {5, 6, 7, 8},
> {9, 10,11,12},
> {13,14,15,16}},
> {{17, 18, 19, 20},
> {21, 22, 23, 24},
> {25, 26, 27, 28},
> {29, 30, 31, 32}}}
>
> I want to plot this matrix, where every number is a unit cube, to give a sort of 3D grid, where the number gives the colour. In reality most numbers would be 0, which would be transparent.
>
> I want to do this as I'm developing a 3D partitioned cellular automaton, and have it defined over structures of this sort, and I want to be able to visualise its development. In 2D I've used MatrixPlot and Animate to do this.
>
> One layer is 1-16, and the second is 17-32.
>
> Any help would be greatly appreciated,
>
> Thanks!

Hi,

you could try something similar to this:

Graphics3D[{Opacity[0.3],
MapThread[{Hue[#1], Cuboid[#2]} &, {Flatten[mat/Max[mat], 2],
Flatten[Array[2 {#1, #2, #3} &, Dimensions(a)mat], 2]}]}]

Cheers,

Markus