I need to generate a 3D plot of a function, say $z = \sin(x)\cos(y)$, with contour lines drawn at specified intervals. I also want to label each contour line with its $z$-value. I have discovered how to superimpose the contour lines on the 3D graph thanks to this post: Adding contour lines to a 3D plot?. However, I still cannot figure out how to label these contour lines with their $z$-values. How can this be done?
Here is an approach exploiting the underlying graphics objects calculation of the contours (in this case level curves):
This is just an approach and particular stylistic preferences could be adapted:
The graphic structure is such that the contours are stored as Line after the lines of the boundary of the plot. I have taken account of possible multiple contours for given value and no contour by using the values from lines available. Doubtless there will be exceptional cases but this is an approach.