Mouse click to get location on Graph and position text

10 ビュー (過去 30 日間)
Jason
Jason 2015 年 5 月 7 日
編集済み: Thomas Koelen 2015 年 5 月 7 日
Is it possible to use a mouse to locate a position on a graph and then add user defined text. ideally using the mouse click callback?
Thanks Jason

採用された回答

Thomas Koelen
Thomas Koelen 2015 年 5 月 7 日
編集済み: Thomas Koelen 2015 年 5 月 7 日
t = linspace(0,2*pi,50);
y = sin(t);
plot(t,y) %Plot anything here, can be an image aswellm, whatever.
[x,y] = ginput(1); %Change the number if you want more than one text
str1 = 'test'; %This is the text displayed
text(x,y,str1) %Adds the text to the graph at x,y
Like this?
With more text:
t = linspace(0,2*pi,50);
y = sin(t);
plot(t,y)
str1 = {'Hello','this','is','Thomas!'};
[x,y] = ginput(length(str1));
text(x,y,str1)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by