Not able to create datatip

Hello all,
I am trying to create a datatip for my plot at a specific point.
my example code is-
x= (1:10);
y = x;
p=plot(x,y);
Whenever I am using- datatip(fig,x,y)
I am getting a warning message- This function is no longer supported. I am using 2019a version.
My second option was to use this-
dcm_obj = datacursormode();
createDatatip(dcm_obj,p, [x(2),y(2)]); But it doesn't show me the correct info instead of creating a datatip at 2nd x and y point it is creating dattip at first point of x&y.
Is there any way this problem can be resolved.
Thanks

3 件のコメント

Adam Danz
Adam Danz 2021 年 5 月 3 日
編集済み: Adam Danz 2021 年 5 月 3 日
Please share the entire copy-pasted error message.
Sameer Singh
Sameer Singh 2021 年 5 月 3 日
this is the snap shot of the code and warning message i am getting
Adam Danz
Adam Danz 2021 年 5 月 3 日
The warning you're seeing is probably something left over from an older undocumented version of datatip() prior to it being released in r2019b.

サインインしてコメントする。

回答 (1 件)

Adam Danz
Adam Danz 2021 年 5 月 3 日
編集済み: Adam Danz 2021 年 5 月 3 日

0 投票

datatip() was not released until r2019b.

3 件のコメント

Sameer Singh
Sameer Singh 2021 年 5 月 3 日
Thank you Adam for this information,
Is there a way I can create datatip programatically in 2019a version by some other method.
Adam Danz
Adam Danz 2021 年 5 月 3 日
編集済み: Adam Danz 2021 年 5 月 3 日
I don't know a method to programmatically place a datatip prior to r2019b.
You could use a text object. Method #5 in this answer is a more elaborate example than the demo below.
x= (1:10);
y = x;
p=plot(x,y);
hold on
txt = sprintf('x = %g\ny = %g',x(2),y(2));
th = text(x(2)-.1,y(2)+.1,txt,'BackGroundColor','w','EdgeColor','k',...
'HorizontalAlignment','right','VerticalAlignment','Bottom');
ph = plot(x(2),y(2),'ko','MarkerFaceColor','c');
Adam Danz
Adam Danz 2021 年 5 月 3 日
You could search the forum for undocumented methods of setting data tips prior to r2019b.
For example,

サインインしてコメントする。

製品

リリース

R2019a

タグ

質問済み:

2021 年 5 月 3 日

コメント済み:

2021 年 5 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by