Annotations with arrows for scatter plot

조회 수: 16 (최근 30일)
Florian
Florian 2018년 10월 11일
댓글: Star Strider 2018년 10월 16일
I have a scatter plot and would like to add labels with arrows for each data point (similar to the example below). I have a cellstring vector called ' labelc' with data labels of the same length as my x and y data vectors. I tried to use the annotation function in matlab to create the labels as follows...
a = annotation('textarrow',x,y,'String',labelc);
...but got an error message:
Error using annotation (line 121) unknown argument
Does anybody know how to achieve this?

채택된 답변

Star Strider
Star Strider 2018년 10월 11일
*‘... with data labels of the same length as my x and y data vectors.’
That could be the problem. The documentation does not appear to support array arguments for them. See if putting the annotation calls in a loop, with one value for each ‘x’, ‘y’, and ‘labelc’ in every iteration works:
for k = 1:...
a = annotation('textarrow',x(k),y(k),'String',labelc(k));
end
Make necessary changes to be certain ‘labelc’ is addressed correctly so it displays correctly.
(I am currently running a long optimization, and cannot test this approach just now.)
  댓글 수: 14
Florian
Florian 2018년 10월 16일
Thanks to Star Strider for the answer - and thanks Jonas for pointing out the pair: you were absolutely correct!
Star Strider
Star Strider 2018년 10월 16일
Our pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by