get line plot data just by mouse stay on it (without click)
5 ビュー (過去 30 日間)
古いコメントを表示
I plot my data and I need to show data (Y) in text box when I put the mouse cursor on it (without click), is there any fuction that help me?
0 件のコメント
採用された回答
Teja Muppirala
2013 年 1 月 28 日
Here is a simple example that outlines how to do it using HITTEST.
function my_example
plot(rand(5));
set(gcf,'windowbuttonmotionfcn',@getcoords)
function getcoords(varargin)
this = hittest;
if strcmp(get(this,'type'),'line');
cp = get(gca,'currentpoint');
ht = title(num2str(cp([1 3])));
set(ht,'color',get(this,'color'));
end
1 件のコメント
Ouael Chkoundali
2019 年 2 月 25 日
Hi Teja,
and if I want to display the mouse position only when it is on an axes? I have a GUI with 1 axes and buttons.
その他の回答 (2 件)
Walter Roberson
2013 年 1 月 28 日
datacursormode() with a custom callback function that sends the coordinate to the edit box as well as displaying it on the screen.
Jan
2013 年 1 月 28 日
You can use the WindowsButtonMotion function of the parent figure. There OVEROBJ can check, if the mouse is over the specified axes and the CurrentPoint property of this axes contains the coordinates. Now you need a method to find the nearest (interpolated?) point of your data for the display.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!