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

조회 수: 29 (최근 30일)
Yiqun Yang
Yiqun Yang 2017년 10월 13일
답변: Elizabeth Dobbins 2019년 2월 25일
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
Elizabeth Dobbins
Elizabeth Dobbins 2019년 2월 4일
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.

댓글을 달려면 로그인하십시오.

답변 (2개)

Estherinha
Estherinha 2019년 2월 14일
Me too, same problem.....

Elizabeth Dobbins
Elizabeth Dobbins 2019년 2월 25일
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.

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by