MATLAB: How to arrange several plots in one figure in 3D space

3d spacearrange plots

My problem is as follows: I have got data from a finite element solver (FlexPDE) that specify the value of a certain variable A in 2D planes (x,y) at different heights z. I can create 2D pcolor and contour plots from these data that show the value of A at given heights, in this case z1,z2 and z3. Now I want to include all these three plots in 3D space in one single figure, where each plot is shown at the height for which its data were calculated (i.e. z=z1,z2,z3 depending on plot). What is the best way to do this?
Essentially, I'm looking for results similar to slice() plots, but in my case I don't have a 3D array of data, but rather several 2D arrays of data. I've tried using slice() by combining the arrays, but I can't edit each 2D plot separately, I think (the colormap is my main issue).

Best Answer

Consider the following example:
[x,y,c] = peaks;
g1 = hgtransform('Matrix',makehgtform('translate',[0 0 -0.5]))
h1 = surface(x,y,zeros(size(z)),z,'Parent',g1)
g2 = hgtransform('Matrix',makehgtform('translate',[0 0 0.5]))
[~,h2] = contour(x,y,z,'Parent',g2)
zlim([-1 1])
view(3)
The hgtransform objects allow you to move their children around by using their Matrix property. I've moved the first hgtransform in - Z, and the second hgtransform in + Z.
The call to surface with zeros as the Z creates the same object that the pcolor command would have, but lets me parent it to the hgtransform object. The contour command is happy using the hgtransform as a parent directly.
You need to tell it you want a 3D view in this case, because none of the plotting commands did that for you.
The result looks like this:
You should be able to modify this to get the effect you want with your data.