Problem: plot is displayed in the whole gui window instead of in the axes object.

I have a function that generates a mesh and plots it. I call this function from a push button object. The generated mesh is displayed in the whole gui window, covering it completely, making the gui useless. The only way I partially solved it, was by calling 'figure' before calling the function. The outcome really baffles me. The mesh is plotted in the axes object as expected and then a blank figure is prompted. Please could anyone help?

Answers (1)

it is not a suitable way in GUI programming. just make a handles.axes1 (Axis) in your GUI and whenever you want to plot something special just make this axis as your place that MATLAB plot data.
axes(handles.axes1);
plot('WHATEVER YOU WANT TO PLOT');

4 Comments

I've already tried that and it doesn't make any difference. Of course I have an axis object in the gui design by the way.
Better:
Do not call axes(handles.axes1);. Instead call
plot(handles.axes1, 'WHATEVER YOU WANT TO PLOT');
The mesh function doesn't use the simple plot function for plotting. It would be simple enough to pass as a first argument the axes handle. For the trisurf function for instance, I did the thing with 'Parent' and then declaring the axes handle, but it still doesn't work. For some reason the mesh is plotted in the axis object, as intended, when I write figure before calling the mesh function from the button callback function, but then a blank figure is prompted as I said in my first post. When I simply declare axes(handles.axes1) in the first line of the code of the mesh generation function, without making any other change in the subsequent code, then an error message saying "Invalid object handle" is prompted when I push the button that calls the mesh generation function. I passed handles as an input in the mesh generation function, does it need something more?
Your axes has been deleted along the way, it sounds like.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Asked:

on 25 Aug 2015

Commented:

on 26 Aug 2015

Community Treasure Hunt

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

Start Hunting!