how to avoid clabel overlap

24 views (last 30 days)
Jing Sun
Jing Sun on 17 Jan 2017
Commented: Jing Sun on 21 Jan 2017
my matlab version is 2015a, when i want to use "clabel(c,h,'labelspacing',100,'fontsize',8);" , it doesn;t work. in the version after 2014, you can only use "clabel(c,'fontsize',8)" to adjust the clabel fontsize. But I don't want the the "+" symbol. How can I use the labelspacing and the fontsize at the same time? Or how to avoid overlap of the clabel, with smaller fontsize and large spacing. Thanks

Answers (1)

Chinmayi Lanka
Chinmayi Lanka on 19 Jan 2017
The "clabel" function allows you to create contour labels and partially customize their appearance.
One approach could be to label the contour plot manually. The following command allows you to click on the plot and MATLAB creates labels at the selected position for the contour line under the mouse:
>> clabel(C,h,'manual')
Click the mouse or press the space bar to label the contour closest to the center of the crosshair. Press the Return key while the cursor is within the figure window to terminate labeling.
There are two possibilities to adjust the density of labels in the entire contour plot when using automatic labelling: 1) Label only a subset of the displayed contour lines:
>> [x,y,z] = peaks;
>> [C,h] = contour(x,y,z);
>> v = [-2 0 6 8]; %Label only the contours with contour levels -2, 0, 6 or 8
>> clabel(C,h,v)
2) Change the spacing between labels on one contour line:
>> [x,y,z] = peaks;
>> [C,h] = contour(x,y,z);
>> clabel(C,h,'LabelSpacing',100) % define space between labels, specified as a scalar value in point units
  1 Comment
Jing Sun
Jing Sun on 21 Jan 2017
because I draw several pictures together, so manual is not possible. And I had tried the labelspacing, there still will be some overlaps. Is there any other way?

Sign in to comment.

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!