MATLAB Answers

1

How to avoid the text from overlapping the contour lines with manual clabel?

Asked by Yiqun Yang on 13 Oct 2017
Latest activity Answered by Elizabeth Dobbins on 25 Feb 2019
When I was using clabel() manually, I've run into a problem:
Z = peaks;
figure;
[C,h] = contour(Z,8,'k');
clabel(C,h,'manual')
I clicked a couple of points to display the text, but the text overlaps with the lines:
What I want should look like this:
The question is, after manually selected the location of the labels, how could I set the spacing around the text so that they do not overlap with the lines?
Thanks a lot!!

  1 Comment

I'm having this same trouble.
I have code that used to work with pre-2014 contours (which made patches) that would manually break the line after the label text was added, but that code no longer works.

Sign in to comment.

2 Answers

Answer by Estherinha on 14 Feb 2019

Me too, same problem.....

  0 Comments

Sign in to comment.


Answer by Elizabeth Dobbins on 25 Feb 2019

I contacted MATLAB technical support. Here's the response I got:
In manual placement mode, the text labels are text objects that are placed on top of the contour object. This gives users full control and flexibility for the label placement, but the labels are now managed independently from the contour, and the contour object doesn't have the information about the labels. Therefore, the contour object will not add gaps to the lines to accommodate the text labels.
If you want to have the space for labels, a workaround is to add a white background color to label text objects, which will obscure the contour lines and make it looks like a gap in the line. But this solution is not ideal, as it will overlap anything (including the fill or other graphics and lines in the contour), but it could be a possible workaround for your workflow.

  0 Comments

Sign in to comment.