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

29 visualizzazioni (ultimi 30 giorni)
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 Commento
Elizabeth Dobbins
Elizabeth Dobbins il 4 Feb 2019
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.

Accedi per commentare.

Risposte (2)

Estherinha
Estherinha il 14 Feb 2019
Me too, same problem.....

Elizabeth Dobbins
Elizabeth Dobbins il 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.

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by