MATLAB Answers

How can I adjust the labels on contour lines in a 'meshc' 3D-plot?

5 views (last 30 days)
I have made a 3D-plot using 'meshc'. I want to adjust the placement of the labels on the contour lines.
The handle return by the 'meshc' is
h =
2x1 graphics array:
Hence, I used the following commands to display the labels.
The labels are too crowded. I want to manually adjust their location and the font size.


Sign in to comment.

Accepted Answer

David J. Mack
David J. Mack on 3 Mar 2017
Hey Ibrahim,
have a look at Contour Properties - the LabelSpacing property might help. Also you can specify your own contour levels (see the Contour Levels property group) which might be used to control the labels indirectly.
Greetings, David


Ibrahim Wasiq
Ibrahim Wasiq on 3 Mar 2017
I want a single label per contour line. The placement of the labels should be such that they do not overlap and clearly represents the line they belong to. I have used 'LabelSpacing' but it doesn't solve the problem.
hContour.LabelSpacing=600; % Default (144)
I have attached the image to make it clear.
David J. Mack
David J. Mack on 3 Mar 2017
Use the clabel function for full control on the lines & labels. With the current plot you cannot achieve your goal. If you want to keep the current lines, a workaround maybe to use a colorbar with color levels matching exactly your contour levels and then label the colorbar accordingly.

Sign in to comment.

More Answers (0)

Sign in to answer this question.