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

1 view (last 30 days)
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)

Morteza
Morteza on 25 Aug 2015
Edited: Morteza on 25 Aug 2015
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
Elisavet Chatzizyrli
Elisavet Chatzizyrli on 26 Aug 2015
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?

Sign in to comment.

Categories

Find more on Graphics Object Programming 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!