How to alter contour label properties?

조회 수: 6 (최근 30일)
K E
K E 2015년 3월 18일
답변: LUIS ALFONSO DIAZ SECADES 2023년 2월 25일
How can I change contour label properties without getting the warning shown below?
[cc, hh] = contourf(peaks);
t = clabel(cc, hh); % This command generates the warning
t.FontWeight = 'bold'; % Does not produce bold font
Warning: Text handle output is not supported for managed labels.
No public field FontWeight exists for class matlab.graphics.GraphicsPlaceholder.
(Can't find any reference to "managed labels" in documentation or clabel code.)
  댓글 수: 1
K E
K E 2015년 3월 18일
편집: K E 2015년 3월 18일
Here it looks like you can either get rotated clabels (necessary for visibility in the data I'm plotting), or you can set the clabel text properties, but not both, for the reasons given here . What I don't understand: Aren't the clabels text objects? Why can't I access them, for example using findobj('type', 'text')?

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

채택된 답변

Rob Comer
Rob Comer 2015년 6월 5일
If you download and install one of the workarounds available here for R2014b or R2015a: http://www.mathworks.com/support/bugreports/1114747, you'll be able to use commands like the following to control the FontWeight of your labels:
clabel(C,h,'FontWeight','bold')
The workaround will enable a total of 12 properties that affect the appearance of contour labels: Color, FontName, FontSize, FontWeight, and 8 others.
  댓글 수: 2
K E
K E 2015년 6월 5일
It worked, and if I apply the text properties as show below, the labels are rotated. If I have no text properties specified, the labels aren't rotated and there is a '+' on each contour. So I will just make sure to specify properties!
[cc, hh] = contour(peaks);
clabel(cc,hh,'FontWeight','bold')
Rob Comer
Rob Comer 2015년 6월 5일
I'm glad it worked for you.
But, actually, you don't have to specify text properties in order to get rotated labels that are placed within the contour lines. You could just include your first two inputs and let clabel use the default properties. It seems likely that you omitted the second input (the contour object handle) along with the text properties. That syntax (contour matrix only, no contour handle) will give you a plot with '+' signs on each contour and upright text.

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

추가 답변 (1개)

LUIS ALFONSO DIAZ SECADES
LUIS ALFONSO DIAZ SECADES 2023년 2월 25일
Hello there,
I have several contour figures where I would like to change font. General text is easy with Property Inspector but I cannot do the contour.
I have *.fig files and tried to generate the code and insert this inside clabel:
'FontName','Times New Roman'
but it did not work.
Any tip on how to exchange contour font in an already generated figure?
Thanks in advance.
Kind regards

카테고리

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