5

I have 3D data which is of the following form:

[(X1, Y1, Z1, VALUE1), (X2, Y2, Z2, VALUE2)...]

X, Y and Z are integers between 1 and 5 and value is an integer greater or equal to zero. So, for example a dataset could look like this:

import numpy as np
x = np.array(range(1,6))
y = np.array(range(1,6))
z = np.array(range(1,6))
data = np.random.randint(1,100, size=(len(x), len(y), len(z)) )

Now I would like to visualize the data in 3D. One possibility would be to plot cubes of different color to fill the space given by the arrays (x,y,z) as shown in the answer here: 3D discrete heatmap in matplotlib

The problem is that there exist 125 cubes.

Is there a better visualization for visualizing the 3D distribution of the data? Ideally, a plot would allow to inspect the different cubes but also an aggregation over some cubes could work.

machinery
  • 5,972
  • 12
  • 67
  • 118
  • 3
    Using [voxels](https://matplotlib.org/3.2.1/gallery/mplot3d/voxels.html) is better approach. 125 cubes are not that much for it. But I find inspecting cubes extremely hard especially covered ones. Unfortunately, matplotlib can't render 3D aggregations correctly. – mathfux Aug 31 '20 at 01:05
  • 1
    This is a bit of a nitpick but if you have x, y, and z coordinates plus a value that is 4 dimensional data, not 3 dimensional. – William Miller Aug 31 '20 at 03:12
  • @mathfux I will try voxels but the problem with it is that cubes in the middle are not visible in the end. That means only cubes at the edge of the axis will be visible. That's why I'm searching for a different visualization approach. – machinery Aug 31 '20 at 09:13
  • @WilliamMiller Yes you are right, then I'm searching a better way to visualize these 4 dimensional data. – machinery Aug 31 '20 at 09:13

0 Answers0