How do I plot points clicked on one plot onto another plot in MATLAB 7.7 (R2008b)?
1 view (last 30 days)
Show older comments
I have two plots and I wish to click on one of these plots and have the points show up on the other plot. Essentially, I want to send the data to the other plot. I may also have issues with the difference between clicking on the axis or the line object since the line object has no 'CurrentPoint' property.
Accepted Answer
MathWorks Support Team
on 21 Jan 2010
This functionality can be achieved by assigning the the 'ButtonDownFcn' callback of the line and axis objects (to be clicked) and by using the fact that the 'CurrentPoint' is updated in the corresponding axis even if the object clicked is a line object.
Download the attached file and run it by typing 'plot2otherfigure'.
The key code in the callback assignments looks like this:
function axis2pnt(src,eventdata,ahto)
p=get(src,'CurrentPoint')
plot(ahto,p(1,1),p(1,2),'r*')
end
function line2pnt(src,eventdata,ahto)
prnt=get(src,'Parent');
p=get(prnt,'CurrentPoint')
plot(ahto,p(1,1),p(1,2),'r*')
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!