MATLAB: How to change the location of the contours produced by MESHC or SURFC in HG1

contourMATLABmeshcpatchsurfc

How do I change the location of the contours produced by MESHC or SURFC in HG1?
I drew a 3-D plot using MESHC. I want to change the contour level since the bottom (z-minimum) is too close to the mesh surface. How can I do this?

Best Answer

To modify the location of the the contours in the plot you need to modify the ZData property. Each contour line is actually an individual patch object. The level at which these contours are drawn is stored in the ZData property of the patch object. Here is a small example:
 
% Create a sample plot
meshc(peaks)
% Define the new level at which the contours should
% be drawn
new_level = 5;
% Get the handle to each patch object
h = findobj('type','patch');
% Create a loop to change the height of each contour
zd = get(h,'ZData');
for i = 1:length(zd)
set(h(i),'ZData',new_level*ones(length(zd{i}),1))
end
For further information on the ZData property of patches please see the MATLAB HelpDesk.