# How to draw multiple cuboids on the same plot

I have defined a table

Table[Table[
Graphics3D[
1 - Cos[kotiDensity[[j, i]]], 0}, {radijDensity[[j, i]]*
Sin[kotiDensity[[j, i]]],
radijDensity[[j, i]] (1 - Cos[kotiDensity[[j, i]]]) +
visina[[j, i + 1]], 0}]], {i, 1, n + m - 10}], {j, 1,
Length[force[[All, 1]]], 1}]


of cuboids.

But what I want is to have all of them on the same plot but at different z axis values. And I don't know how to do it. Something like ListPlot3D just that I want it to show those cuboids.

• "different z axis values" - then you should be changing the $z$-coordinates on the corners of the Cuboid[], no? – J. M. will be back soon Aug 3 '15 at 11:38
• I think not. Because doing so, will add third dimension to the cuboids. And I don't want that. I want them to remain 2D - so it is actually a rectangle but I used Cuboid[] in mathematica only because I want a 3D plot. So the idea is if you imagine an arbitrary shaped sasuage (3D object) I want to show only some slices at specified z values, if z axis is along the sausage. Is that understandable? – skrat Aug 3 '15 at 11:56
• Oh yeah... And by "all" cuboids I mean for all indexes i at given index value j, if I use the same notation as in the OP. The idea is to than use Manipulate[] for index j. – skrat Aug 3 '15 at 12:59

Its difficult to work with your question since you don't define your functions and variables but hopefully this example will be enough.

Let's first make a table of cuboids with different z values (but using the same z-value within each cuboid so they are still rectangles). This examples uses the same x and y values for every Cuboid for simplicity, but you can obviously change that.

list = Table[Cuboid[{0, 0, z}, {1, 1, z}], {z, 1, 5}]


Now apply Graphics3D to the list of cuboids

Graphics3D @ list By putting different z values for each cuboid, they appear at different levels.

• Doesn't Graphics3D @ list work? – Michael E2 Aug 3 '15 at 13:41
• Yes, it actually does. I'm still somewhat new to Mathematica and didn't know Graphics3D could take multiple regions until you said that. I'll modify the post since that is cleaner. Thanks! – BenP1192 Aug 3 '15 at 13:47
• You're welcome! – Michael E2 Aug 3 '15 at 13:47

Something like ListPlot3D just that I want it to show those cuboids.

If you need to place the same shape at multiple points either in 2D or 3D, the best solution is Translate. It can take more than one translation vector as the second argument.

Example:

pts = RandomReal[10, {20, 3}];

Graphics3D[
Translate[
Cuboid[],
pts
]
] 