# Combine Multiple ListDensityPlots into 3D Cube

I am wondering if anyone has suggestions on how best to go about creating an image of several ListDensityPlots merged into a single 3D cube (with only the axes, not the full frame). For example, I have the following 4 ListDensityPlots:

data1 = Table[Sin[j^3 + 2 i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
data2 = Table[Sin[j^2 + i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
data3 = Table[2 Sin[x y], {x, 0, Pi, Pi/5}, {y, 0, Pi, Pi/5}];
data4 = Table[( Cos[i j] - 3 j), {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
p1 = ListDensityPlot[data1, Mesh -> None,
ColorFunction -> "AtlanticColors", InterpolationOrder -> 3];
p2 = ListDensityPlot[data2, Mesh -> None,
ColorFunction -> "AtlanticColors", InterpolationOrder -> 3];
p3 = ListDensityPlot[data3, Mesh -> None,
ColorFunction -> "AtlanticColors", InterpolationOrder -> 3];
p4 = ListDensityPlot[data4, Mesh -> None,
ColorFunction -> "SunsetColors", InterpolationOrder -> 3];


What I am trying to do is visualize them as vertical slices in a cube. Unfortunately, the data I am actually using are not from the same distribution, but rather represent flow from distinct rivers over date (z-axis) and time (x-axis). From what I understand, I don't think ListSliceContourPlot will work here, or is there a trick I could use to make it work that I'm just not seeing?

Honestly, any help would be greatly appreciated.

Cheers!

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Sep 7 '15 at 1:34
• Could you include your actual dataset, or at least a portion of it? It still seems to me that one should be able to tweak ListSliceDensityPlot to work for you. – MarcoB Sep 7 '15 at 2:35

## 2 Answers

Here's how ListSliceDensityPlot3D would work. Modify your data as follows:

data1 = Table[{i, 0, j, Sin[j^3 + 2 i]}, {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
data2 = Table[{i, 2, j, Sin[j^2 + i]}, {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
data3 = Table[{x, 4, y, 2 Sin[x y]}, {x, 0, Pi, Pi/5}, {y, 0, Pi, Pi/5}];
data4 = Table[{i, 6, j, (Cos[i j] - 3 j)}, {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];


This assumes you want vertical slices in x and z at each of the y-values 0, 2, 4, and 6. You can then combine your data into one list as

data = Flatten[Join[data1, data2, data3, data4], 1];


Finally,

ListSliceDensityPlot3D[data, {"YStackedPlanes", {0, 2, 4, 6}]


I'm not sure that you can specify different color schemes for different slices, but the result of the above is It doesn't look great! And I think that's because each slice is on the same scale, and so if one of your sets of data has a larger width, then the other slices aren't going to show as many features.

You might want to look at

Okay, thanks to the advice above, I've found the trick.

data1 = Evaluate[
Table[Sin[j^3 + 2 i], {i, 0, Pi, Pi/20}, {j, 0, Pi, Pi/20}]] // N;
data2 = Evaluate[
Table[Sin[j^2 + i], {i, 0, Pi, Pi/20}, {j, 0, Pi, Pi/20}]] // N;
data3 = Evaluate[
Table[2 Sin[x y], {x, 0, Pi, Pi/20}, {y, 0, Pi, Pi/20}]] // N;
data4 = Evaluate[
Table[( Cos[i j] - 3 j), {i, 0, Pi, Pi/20}, {j, 0, Pi, Pi/20}]] // N;
(* Transpose the data *)
data = Transpose[{data4, data3, data2, data1}];

(* Create separate ListSliceDensityPlot3D graphics for each style *)
ls1 = ListSliceDensityPlot3D[data, {"YStackedPlanes", {2, 3, 4}},
ColorFunction -> "AvocadoColors", Boxed -> False];
ls2 = ListSliceDensityPlot3D[data, {"YStackedPlanes", {1}},
ColorFunction -> "SunsetColors", Boxed -> False];

(* Combine in show as one *)
Show[ls1, ls2] 