This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Highlight Specific Contour Levels

This example shows how to highlight contours at particular levels.

Define Z as the matrix returned from the peaks function.

Z = peaks(100);

Round the minimum and maximum data values in Z and store these values in zmin and zmax, respectively. Define zlevs as 40 values between zmin and zmax.

zmin = floor(min(Z(:))); 
zmax = ceil(max(Z(:)));
zinc = (zmax - zmin) / 40;
zlevs = zmin:zinc:zmax;

Plot the contour lines.


Define zindex as a vector of integer values between zmin and zmax indexed by 2.

zindex = zmin:2:zmax;

Retain the previous contour plot. Create a second contour plot and use zindex to highlight contour lines at every other integer value. Set the line width to 2.

hold on
hold off

See Also

| | | | |