MATLAB Answers

0

Selecting points from UI Axes App Designer MATLAB R2019a

Asked by Hemanth Hariharan on 12 Aug 2019
Latest activity Answered by Abhilash Padma on 16 Aug 2019
I am plotting this histogram on UI Axes App Designer R2019a, and I want the user to be able to interactively split the plot using vertical lines (so that I can get the X coordinate at which they are placed). I was previously using getpts, which does not seem to work on UI Axes. Is there a solution for this?

  0 Comments

Sign in to comment.

Products


Release

R2019a

1 Answer

Answer by Abhilash Padma on 16 Aug 2019
 Accepted Answer

I understand that you want to split the plot using vertical lines whenever you click on the axes. But, there is no built-in functionality of adding callbacks to UIAxes as of now. Rather, consider using the ButtonDownFcn callback of plot object to draw vertical lines. Here, the plot object can be used to get your expected output.The following code below may help you solve the problem.
p=plot(app.UIAxes,1:10);
p.ButtonDownFcn=@mouseClick;
function mouseClick(~,~)
cp=get(app.UIAxes,'CurrentPoint');
xline(app.UIAxes,cp(1,1));
end

  0 Comments

Sign in to comment.