필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problem with plot occupying whole GUI area rather than 'axes' figure area. Using library function and not 'plot'.

조회 수: 1 (최근 30일)
Hi,
I created a GUI and an 'axes' element where I would like to plot a figure. I have tried using axes(handles.main_plot). This works when I test it with a plot(x) command. Though I am using an external library function to plot, and with this the problem is not solved. (I cannot use plot(handles, ...) as I would need to modify the function).
The external function I am using is GoodnessOfFit of the library psignifit.
I also get an error regarding the line 'gui_mainfcn(gui_State, varargin{:});'. And, if I try to press the 'plot the figure' button a second time (after the GoodnessOfFit function has plotted the figure over the whole GUI area) I get an error at the line where I specify the handles, 'invalid object handle'. Both of these errors do not appear if I create a new figure (opening outside the GUI) before calling GoodnessOfFit. Is the function deleting my handle, and if so, is there a way to avoid this without modifying the function itself?
Thank you

답변 (1개)

Walter Roberson
Walter Roberson 2016년 10월 18일
The source code for that GoodnessOfFit routine starts with
ax = subplot(231);
cla(ax);
plotPMF ( inference, 'axes', ax );
ax = subplot(232);
cla(ax);
plotRd ( inference, 'p', 'axes', ax );
ax = subplot(233);
cla(ax);
plotRd ( inference, 'k', 'axes', ax );
so it works with the current figure but it will soon erase anything that is in the top three subplots. subplot() also has the behaviour of deleting any axis that it overlaps, so if your existing setup did not already subplot the figure more finely than 2 x 3, then it would probably remove the axes.
Your option at this point is to create a new figure before calling the routine, let it draw what it wants, and then grab the subplot axes you want from the new figure and set its Parent to be the container of axes(handles.main_plot) and set the Position to be suitable. You could instead copy the contents of the axes to handles.main_plot but it is easy to miss some parts

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by