

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer

I am trying to create something similar to a Heatmap within a building. Suppose I have a room with dimensions, {30,40,50} as length, width, and height respectively. I have a set of data that is of the form {x,y,z,temp} where x,y,z represent the coordinates of the room along the axis of the room, and temp is the temperature at a particular point. My idea is to create a color coding scale like this. If the temp is between 25-30 degrees, then the color at the cordinates within the building is blue, if the temp is between 30-35 degrees, then the color is green, if the temp is between 35-40, the color at that point is red. If there is no temp data available, that particular point should be just a transparent block. I need to arrange cuboids in rows that are predetermined like say, 30 cubes along the length of the building, 40 cubes along the width of the room, and 50 cubes along the height of the building. More correctly, I dont the shapes to be points or cuboids of equal sides but rather readjusting based on the dimensions of the building that I can rearrange along the building. I am trying to achieve something like this, but to readjust itself along the dimensions of the building.

I am able to generate the point codes, cuboid data, hues. But I want more precise color coding like the way I have mentioned in the question.


 w = 30;
 l = 40;
 h = 50;
 m = 40;
 backwall = {{0, l, 0}, {w, l, 0}, {w, l, h}, {0, l, h}};
 side1 = {{0, 0, 0}, {0, 0, h}, {0, l, h}, {0, l, 0}};
 side2 = {{w, 0, 0}, {w, 0, h}, {w, l, h}, {w, l, 0}};
 floor = {{0, 0, 0}, {w, 0, 0}, {w, l, 0}, {0, l, 0}};
 top = {{0, 0, h}, {w, 0, h}, {w, l, h}, {0, l, h}};
 front = {{0, 0, 0}, {w, 0, 0}, {w, 0, h}, {0, 0, h}};
 leftRoof = {{0, 0, h}, {w/2, 0, (h + m)}, {w/2, l, (h + m)}, {0, l, h}};
 rightRoof = {{w, 0, h}, {w/2, 0, (h + m)}, {w/2, l, (h + m)}, {w, l,h}};
 roofBack = {{w, l, h}, {w/2, l, (h + m)}, {0, l, h}};
 roofFront = {{w, 0, h}, {w/2, 0, (h + m)}, {0, 0, h}};
 data = RandomReal[{0, 60}, {10000, 3}];
 binning1 = {0, 50, 2};
 binning2 = {0, 60, 2};
 binning3 = {0, 40, 2};
 binned = BinCounts[data, binning1, binning2, binning3];
 dims = Dimensions@binned;
 coordswithdataAll = Table[{x, y, z, x + y + z}, {x, 1, dims[[1]]}, {y, 1, dims[[2]]}, {z, 1, dims[[3]]}];
 coordswithdata = coordswithdataAll;
 myTemperatureMap[Null] := {Opacity[0]};
 myTemperatureMap[t_] := {Opacity[.2],ColorData["TemperatureMap"][Rescale[t, {25, 40}]]}
 temps = Flatten[coordswithdata, 2][[All, 4]];
 coords = Flatten[coordswithdata, 2][[All, 1 ;; 3]];
 cubes = Graphics3D[{Flatten@MapThread[{#1, Cuboid[#2]} &, {myTemperatureMap /@ temps, coords}]}];
 fig = Graphics3D[{Opacity[0.3],Style[Polygon[{backwall, side1, side2, floor, front, leftRoof, rightRoof, roofBack, roofFront}],Lighting -> {{"Ambient", Green}}]}, AxesLabel -> {x, y, z}, Boxed -> False, RotationAction -> "Clip"];
 Show[fig, cubes] 

What I want to do is to is to arrange the cuboids in a very nice along the length,width, breadth of the warehouse to provide for a visualization for the heat maps within the warehouse.

Any pointers, thanks and regards,Anu

share|improve this question

Here's a simple way to create your own color scale based on Mathematica's ColorData["TemperatureMap"]:

myTemperatureMap[Null] := {Opacity[0]}
myTemperatureMap[t_] := {Opacity[1], 
  (* use Opacity[0.5] or less in more complicated 3D graphics *) 

Some exemplary data:

temps = {25, 30, , 35, , 40};
coords = {#, 0} & /@ Range@6;

And the result:

  MapThread[{#1, Disk[#2, 0.5]} &, {myTemperatureMap /@ temps, coords}]]

enter image description here

Or using "Rainbow" insted of "TemperatureMap" to get green in between:

enter image description here

You might also want to look into guide/ColorSchemes in the documentation.

share|improve this answer

Your Answer


