Code covered by the BSD License  

Highlights from

image thumbnail




21 May 2008 (Updated )

Like subplot, but easier, and WYSIWYG export to file. Also fixes dashed/dotted lines in export.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

% You can have as many Panels as you like in one Figure.
% (a) Create a figure with two uipanel objects.
% (b) Attach a panel to one of these.
% (c) Attach another - oh, wait!

%% (a)

% create the figure

% create a couple of uipanels
set(gcf, 'units', 'normalized');
u1 = uipanel('units', 'normalized', 'position', [0.1 0.1 0.35 0.8]);
u2 = uipanel('units', 'normalized', 'position', [0.55 0.1 0.35 0.8]);

%% (b)

% create a 2x2 grid in one of the uipanels
p = panel(u1);
p.pack(2, 2);'all');

% see?

%% (c)
% and, what the hell, another in the other
q = panel(u2);
q.pack(2, 2);'all');

% oh, wait, the first one's disappeared. why?

% by default, only one panel can be attached to any one
% figure. this makes for ease of use, usually. if you want
% to attach more than one, you have to pass the 'add'
% argument to the constructor when you create additional
% panels.
p = panel(u1, 'add');
p.pack(2, 2);'all');

% see?

% and, of course, if we try to create a new one again, once
% again without 'add', we'll delete all existing panels, as
% before...
p = panel(u1);
p.pack(2, 2);'all');

% see?

% finally, let's delete the first one, just for the craic.

Contact us