I have 4 plots to make, of vectors y1, y2, y3 and y4, all as a function of a vector x. I would like the first two plots to be grouped as tabs within a single Figure window, and the next two plots also grouped as tabs 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 tab grouping is re-enabled, plots are just added as new tabs appended to the old window rather than in a new window.
I played around with the order of the commands above but it didnt help. If anything, I only managed to get one of the plots overwritten in the same window. Please note i don't want any of the graphs to overlap, therefore "hold on" would not help.
Any suggestions? Thanks!
Much like files in the Editor, figures can either be free-floating or docked to the "Figures" window (which only appears when something is docked to it, and can itself either be free floating or docked to the "Desktop" window). Since there's only a single global "Figures" window, the closest you can get is splitting it into panes and having a group of tabs per pane (interactively, at least - I'm not sure if there's a programmatic interface to that).
However, that's only considering the top-level UI. It's perfectly possible to have multiple figures, each containing tabbed plots, 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
and uitabgroup
are "new" in R2014b, but exist in undocumented, unsupported form in earlier versions - the above example worked fine for me on both R2013b and R2006b.