Gui - Two plots in new figure - handles
3 次查看(过去 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
0 个评论
回答(2 个)
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
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
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');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!