How do I control the number of labels plotted using CLABEL?
79 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Commented: Pat
on 11 May 2023
I want just one label per contour when using CLABEL.
Accepted Answer
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
More Answers (0)
See Also
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!