How do I control the number of labels plotted using CLABEL?

79 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
There is no direct way of specifying the number of labels to plot on the contour. However, if you need just one label per contour, you can use call the CLABEL with just one parameter, the contour matrix output. For example:
[X,Y] = meshgrid(-2:.2:2,-2:.2:3);
Z = X.*exp(-X.^2-Y.^2);
[c h] = contour( X, Y,Z);
clabel(c) % This will produce only one label per contour.
PLEASE NOTE: The position of these labels will be random.
Alternately, you can use the manual mode for CLABEL as follows:
clabel(c, 'manual')
This will give you the complete control of where to place the labels with the help of the mouse.
The other way around is to specify the 'labelspacing' property of the CLABEL as follows:
clabel(c,h, 'labelspacing', 700);
This will space the labels on each contour by 700 pixel length. You can adjust this length until you get the desired results.
  1 Comment
Pat
Pat on 11 May 2023
If you are still having this issue, please create a MathWorks Technical Support case. We would be happy to help you out.
https://www.mathworks.com/support/contact_us.html

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!