Clear Filters
Clear Filters

How to create large figure from GUI axes?

2 views (last 30 days)
Johnny Birch
Johnny Birch on 16 Dec 2018
Commented: Rik on 16 Dec 2018
Hi guys
I have a very simple GUI made in guide where i have a plot function initiated by a pushbutton which plots a scatter plot in axes (called Method1axes1):
handles.plot = scatter(X,Y, 'parent', handles.Method1axes1);
Now I want the user to be able to click the axes (plot) to get en new larger figure. I tried the below code which is working if i DON'T plot in the axes first. As soon as I run the plot function the scatterplot appears in Method1axes1 but I can no longer click the figure.
% --- Executes on mouse press over axes background.
function Method1axes1_ButtonDownFcn(hObject, eventdata, handles)
figure
scatter(X,Y);
What am I doing wrong?

Answers (1)

Rik
Rik on 16 Dec 2018
Many functions that place content in an axis will reset a lot of properties. As an example: imshow will wipe most properties of its parent axis, while the image function will not. One of the properties that is removed often is the ButtonDownFcn (along with the other interaction callbacks), so you should check if that property is still as it should be.
You can try to prevent this by using hold on (or setting the NextPlot property of your axes obect), or setting the callback property every time you plot your data.
  2 Comments
Johnny Birch
Johnny Birch on 16 Dec 2018
Hi Rik
i can get it to work. I am a novice i matlab programming, so maybe I am doing it wrong gow would you write your auggestions into my code?
Rik
Rik on 16 Dec 2018
You wrote some code. What did you write exactly? Which of my two suggestions did you try?
Also, please don't post the entire code in a comment, but attach it as an m-file. GUIDE makes for extremely bloaty code.

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Products


Release

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!