How can i exactly click on a point that has drawed on a plot using ginput ?
4 ビュー (過去 30 日間)
古いコメントを表示
Hello!
My problem is:
I have had some points on a figure use plot command with this command lines:
figure;
hold on
x = [1 2 3 4 5]
y = [7 8 9 10 11]
for i = 1:5
plot(x(i),y(i),'*','MarkerSize',12,'Color','r')
end
% Retrieve coordinate of points
[xx,yy] = ginput(length(x))
Now, I want to use ginput() or getPoint() to click on anypoint in the figure.
But, It is difficult to click on a point exxactly.
For example, i want to click on first point that has x = 1 and y = 7. But, when i trying to click on it to retrieve its coordinate, what matlab returns is that i expect (x = 1,y = 7)..
How can i do?????
Please help me!
Thank you so much!
4 件のコメント
Jan
2019 年 1 月 11 日
Why not? Why can't you click on the wanted points? Which problem do you want to solve? To determine the point nearest to the location you click on? To do this, clicking on a specific location is not needed. Why do you think clicking on an exact location is useful? Remember that the point [1.000000000000000, 7.000000000000000] might not be exactly represented by a pixel, but of course you can select a single pixel only. This means that clicking on a specific coordinate is not possible or at least extremely hard using a massive zooming. So why do you want to do this at all?
採用された回答
Jan
2019 年 1 月 11 日
編集済み: Jan
2019 年 1 月 11 日
Considering my comment, my answer is:
You can't. You would need a massive zooming to try to do so. Remember, that [1.000000000000000, 7.000000000000000] is not necessarily represented by a pixel on the screen, but selecting a pixel is the maximum achievable resolution.
The solution is to adjust your needs: What about finding the point nearest to the selected pixel?
What about using the ButtonDownFcn of the drawn points instead of ginput?
4 件のコメント
Timon Rayis
2019 年 10 月 30 日
@Jan
Can you please explain about ButtonDownfcn briefly?
Is that an alternate for ginput?
Jan
2019 年 11 月 4 日
The ButtonDownFcn is a property of the object e.g. created by plot or line. Example:
AxesH = axes;
LineH = line(1:10, rand(1,10), 'ButtonDownFcn', {@myCallback, AxesH});
function myCallback(LineH, EventData, AxesH)
disp(AxesH.CurrentPoint)
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!