Group shapes separately in windows and tabs

I have 4 plots for the vectors y1, y2, y3 and y4, all as a function of the vector x. I would like the first two plots to be grouped as tabs in one plot window, and the next two plots to be grouped as tabs as well, but in a separate window.

I tried this code:

figure
set(0,'DefaultFigureWindowStyle','docked')
plot(x,y1)
plot(x,y2)
figure
set(0,'DefaultFigureWindowStyle','normal')
plot(x,y3)
set(0,'DefaultFigureWindowStyle','docked')
plot(x,y4)

      

.. but once the tab is grouped again, the charts are simply added as new tabs added to the old window, not the new window.

I played around with the order of commands above but it didn't help. Anyway, I managed to get one of the graphs overwritten in the same window. Note that I don't want any of the graphs to overlap, so holding would not help.

Any suggestions? Thank!

+3


source to share


1 answer


Like files in an editor , numbers can either float freely or docked to the Numbers window (which only appears when something is docked to it and can either float freely or dock to the Desktop window). Since there is only one global Numbers window, the closest you can get is splitting it into panels and having a group of tabs per panel (interactively, at least I'm not sure if there is a programming interface there).

However, this only applies to the top-level interface. It is perfectly possible to have multiple shapes, each containing tabs, if you do a little extra work to implement your own tabs:



hfig1 = figure('WindowStyle','normal');
htabgroup = uitabgroup(hfig1);
htab1 = uitab(htabgroup, 'Title', 'Plot A');
hax1 = axes('Parent', htab1);
plot(hax1, x, y1);
htab2 = uitab(htabgroup, 'Title', 'Plot B');
hax2 = axes('Parent', htab2);
plot(hax2, x, y2);
% and so on... helper functions might make sense if you're doing a lot of this

      

Note that uitab

both uitabgroup

are "new" in R2014b, but exist in an undocumented, unsupported form in earlier versions - the above example worked fine for me on both R2013b and R2006b.

+1


source







All Articles