# DensityPlot on a Plane in ListPlot3D

TL;DR: I want to plot a 2D function on the $$z=0$$ plane of a 3D plot and have no idea how to do so.

I have a set of experimental data and a function giving its theoretical value. Say these are given by datastuff and th[input1,input2], respectively. The format of datastuff's entries is {input1,input2,output}. Now say I make two plots:

resids = Table[{datastuff[[i, 1]], datastuff[[i, 2]],
Abs[datastuff[[i, 3]] -
th[datastuff[[i, 1]], datastuff[[i, 2]]]]}, {i, 1,
Length[datastuff]}];
Data=Show[ListPointPlot3D[datastuff],Plot3D[th[ph1,ph2],{ph1,0,2Pi},{ph2,0,2Pi}]]

Errors=ListDensityPlot[resids]


I want to have the flat 2D colorplot "Errors" plotted on the $$z=0$$ plane underneath the "Data" plot. How do I do this? I don't even know where to start!

• Would 164663 be of some help?
– Syed
Commented Feb 23, 2022 at 19:34

If I understand correctly, you want a 3D plot and beneath it a 2D plot depicting some error by color. This makes only sense if the error is systematic and not random. A random error would produce random colors and the density would be approx. uniform.

As you can not combine a 3D plot and a 2D plot, we make the density plot artificially 3D by adding a very small random z component. The z component can not be constant because of ListDensityPlot3D.

For an example, we first need some data:

fun[x_, y_] = Exp[x^2 - y^2];
err[x_, y_] = 0.1 (-x^2 + y^2);
dat = Flatten[
Table[{x, y, RandomReal[{0, 10^-1}], err[x, y]}, {x, -1, 1,
0.1}, {y, -1, 1, 0.1}], 1];


As you see, I assume a systematic error here. We may now makes a plot of the function and a fake "D plot underneath by:

Show[Plot3D[fun[x, y], {x, -1, 1}, {y, -1, 1}],
ListDensityPlot3D[dat, PlotLegends -> Automatic],
PlotRange -> {0, 2.5}
]


• That looks like it'll work! Thank you very much. Commented Feb 23, 2022 at 21:55