How can I get CurrentPoint to display the coordinates within a figures axes rather than the coordinates of the whole figure itself.
21 次查看(过去 30 天)
显示 更早的评论
Hi Everyone,
I'm totally new to matlab so please bear with me.
I've created a GUI using GUIDE which converts and plots data from .BIN files (not important but just to give context) and I want to be able to view the cursors current position relative to the axes scale.
I've managed to get the cursor position relative to the figure window by using
new_point = get(handles.figure,'CurrentPoint');
set(handles.editbox,'String',new_point)
but since the axes don't have a 'CurrentPosition' nor a callback for 'WindowButtonMotionFcn' I can't seem to get values relative to my axes.
Is the only way to get around this to multiply the 'CurrentPosition' result (in my case 'new_point') by a vector equation which corresponds to the axes I've created, or is there another way to get around this?
In an ideal world I would be able to use DataCursor but unfortunately I'm using MATLAB version 6.1.
I'll be ever so grateful for any insight anyone could lend on this,
Thanks,
Rosie
0 个评论
采纳的回答
更多回答(2 个)
Simon Thalén
2015-6-19
Im using get(handle,'CurrentPoint') within my own callback for buttonpress so i really don't want to use ginput..
I found out that when i replaced my handle for axes with simply gco it gave me the correct coordinates. I.E coordinates on the format of my axes if that makes any sense.
So for anyone having the same problem as Rosie try that
0 个评论
William Chamberlain
2018-4-12
gcf_currentpoint = get(gcf, 'CurrentPoint')
gives the pixel coordinates
axes_handle = gca
pt = get(axes_handle, 'CurrentPoint')
gives the relative position inside the axes (top right is 1,1 - bottom left is 0,0)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!