MATLAB: Switch colormap targeted axis

axis targetcolormap

Hi,
It is super easy to switch the axis while using a "surf / mesh like function" (simply by switching the X,Y,Z order in surf(X,Y,Z) )
However, when adding a colormap I didn't find anywhere how to also switch the colormap targeted axis. Meaning if I write surf(Z,Y,X), the colormap will target the third element, which is X here, not Z axis, the one I would like for the same rendering.
Do you have any idea of how I could do this ?
Thank you
Nicolas
Edit : for example with this code :
[X,Y,Z] = peaks(64);
surf(Z,X,Y);
I would like of course the colormap to be in the depth direction.

Best Answer

So simple, so clever !
Great thank Adam, I was struggling with much more complex tries.