Additional text on contour lines

조회 수: 24 (최근 30일)
mkmat
mkmat 2015년 5월 11일
댓글: Preeti Sar 2018년 1월 15일
Hi,
I have a contour and want to add some specific text on one of the contour lines.
For example:
------------------------------------
Z = magic(4);
[C,h] = contour(interp2(Z,4));
h = clabel(C,h);
set(h,'BackgroundColor',[1 1 .6],'Edgecolor',[.7 .7 .7])
------------------------------------
How can I add a text on the line with label 8 in the plot - for example, 'Margin'.

답변 (2개)

Thomas Koelen
Thomas Koelen 2015년 5월 11일
Try using the CLABEL function to get the text object handles and then set the text object "String" property to the text you want. Something like this:
[C,h] = contour(peaks(20),3);
th = clabel(C,h);
set(findobj(th,'String','0.59778'),'String','Base Line')
where '0.59778' is the numeric label of the line whose label you want to change and 'Base Line' is the label you want that line to use.
  댓글 수: 1
Preeti Sar
Preeti Sar 2018년 1월 15일
Hello, I think the string property has been removed from MATLAB R2017b. How do I add string labels to my contours now? Thanks!

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


mkmat
mkmat 2015년 5월 11일
thank!

카테고리

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