MATLAB Answers

Selecting points from UI Axes App Designer MATLAB R2019a

198 views (last 30 days)
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.

Accepted Answer

Abhilash Padma
Abhilash Padma on 16 Aug 2019
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

  1 Comment

Manoj Malviya
Manoj Malviya on 17 Jan 2020
I got an error:
Undefined function 'mouseClick' for input arguments of type 'matlab.graphics.chart.primitive.Line'.
Error while evaluating Line ButtonDownFcn.
Please let me know what can be done

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2019a

Translated by