I am plotting data as a surface in matlab. I have three data matrices, x,y,z.
The values of z may not be outside the range 0~1.
I generate plots with the following:
surf(x,y,z);
[c,h] = contour3(x,y,z,'LevelList',[0 : 0.1 : 1],'Color','k');
clabel(c,h,[0 : 0.1 : 1]);
I also do some modifications to the surface, such as setting shading interp
.
As you can see, the result image clips the contours with the underlying surface. How can I ensure that the contour and labels are plotted above the surface?
After some digging in the doc, I have found the best solution.
The clipping order is specified at the
axes
level.A complete MWE to have the contours always on top of the surface is below:
You can try working on the properties of the
contour
patches: increase thelinewidth
of the patch' edge: the default value is 0.5: alinewidth
of 1 or 1.5 should be enough.On the same way you can set the properties of the lavels generated by
clabel
: you can set thefont size
andfont weight
to make them more visible. Also you can set the number of label to be added by specifying thelabelspacing
property.An interesting option could also be to manually set the labels: this can be done by specifying the
manaul
property in theclabel
call.In the following you find an example based on the
peaks
surface:Hope this helps.