Integer values on contour plots displayed differently to decimalised values?

8 views (last 30 days)
Hi All,
Strange one really but I have noticed that integer values on contour plots ('ShowText') are displayed differently to those with a decimal part e.g. 3 will be postioned and displayed slightly differently to 3.1
I believe this could be solved if I could get Matlab to replace 3 with 3.0 but I do not know how to do this?
The reason it is annoying is the integer values are displayed with less white space around them making them less legible.
If anyone has any advice this would be useful, thanks!
Pascal.

Accepted Answer

Andrew Newell
Andrew Newell on 14 Apr 2011
Suppose you have labeled the contours using commands like these:
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
text_handles = clabel(C,h,'LabelSpacing',72);
You now have an array of handles, one for each label. You can increase the space around them using
set(text_handles,'Margin',6) % put whatever number you like here
However, this margin won't show unless you also assign a color to the text box using a command like
set(text_handles,'BackgroundColor','w')
You can see what other properties can be set using
set(text_handles(1))
and their current values using
get(text_handles(1))

More Answers (1)

Pascal Galloway
Pascal Galloway on 15 Apr 2011
Thank you! This is exactly the answer I was after, very helpful!

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!