필터 지우기
필터 지우기

Gui - Two plots in new figure - handles

조회 수: 8 (최근 30일)
ilas nasiopoulos
ilas nasiopoulos 2015년 6월 22일
댓글: ilas nasiopoulos 2015년 6월 23일
Hello,
I created a gui, and I had two plots in my figure. To plot on each I was using plot(handles.NameofPlot1,x,y) and it was working fine. By changing basically the NameofPlot to the tag name of each of the plots I could plot on the one I wanted.
However, I would like to have the two plots in a different figure.
So I created a new figure (newFig.fig) which also automatically created a new .m file (newFig.m).
I put in there my two plots.
How can I plot on each? Or in other words, how can handle these two plots from my first .m file?
If I do fig=figure(newFig) and then plot(x,y) it will of course always plot on the same.
Can I have some help please?
Many thanks, Elias

답변 (2개)

Geoff Hayes
Geoff Hayes 2015년 6월 23일
Elias - from your example, it sounds like you have two GUIs and you want to plot the data on each one (though it isn't clear to me why you need GUIs to do this when simple figures would suffice).
If you want to pass data between the two GUIs (so that you can plot on any axes of either GUI), then see http://www.mathworks.com/matlabcentral/answers/146215-pass-data-between-gui-s for an idea on how to accomplish this.
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 6월 23일
GUI and "figure" are identical in MATLAB. You can have multiple figures and you can have multiple axes per figure.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2015년 6월 23일
f1 = figure(); %you can add Unit and Position parameters
ax1 = axes('Parent', f1); %you can add Unit and Position parameters
f2 = figure(); %you can add Unit and Position parameters
ax2 = axes('Parent', f2); %you can add Unit and Position parameters
plot(ax1, rand(20,1), 'r');
plot(ax2, randperm(25), 'g');
  댓글 수: 1
ilas nasiopoulos
ilas nasiopoulos 2015년 6월 23일
Thanks a lot. However this is plotting in two different figures/gui (f1 and f2). No?
What if in the second figure I have two plots? Let's say...:
Figure/gui 1 --> code, button, plots figure/gui 2 --> plot2 and plot3
I am having a button on figure 1 which when I press I want to plot on figure 2, plot2 or plot3
Does it make sense now?
I actually found a solution around it, which was to pass all the variables for the plot into the new figure when I call it, and then plot the data calling the plot2 and plot3 with the handles plot(handles.plot2,x,y). I would like to know though if there is a more direct method without having to pass the variables.
Many thanks, Elias

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by