Gui - Two plots in new figure - handles

5 次查看(过去 30 天)
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