How to alter contour label properties?

3 views (last 30 days)
K E on 18 Mar 2015
Commented: Rob Comer on 5 Jun 2015
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
(Can't find any reference to "managed labels" in documentation or clabel code.)
  1 Comment
K E on 18 Mar 2015
Edited: K E on 18 Mar 2015
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')?

Sign in to comment.

Accepted Answer

Rob Comer
Rob Comer on 5 Jun 2015
If you download and install one of the workarounds available here for R2014b or R2015a:, you'll be able to use commands like the following to control the FontWeight of your labels:
The workaround will enable a total of 12 properties that affect the appearance of contour labels: Color, FontName, FontSize, FontWeight, and 8 others.
Rob Comer
Rob Comer on 5 Jun 2015
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!