MATLAB Group Objects

Group objects enable you to treat a number of axes child objects as one group.
For example, you can make the entire group visible or invisible.

Contents

Example

Y = rand(5);
disp(Y)
    0.1690    0.5470    0.1835    0.9294    0.3063
    0.6491    0.2963    0.3685    0.7757    0.5085
    0.7317    0.7447    0.6256    0.4868    0.5108
    0.6477    0.1890    0.7802    0.4359    0.8176
    0.4509    0.6868    0.0811    0.4468    0.7948

barseries

  BAR(X,Y) draws the columns of the M-by-N matrix Y as M groups of N
  vertical bars.  The vector X must not have duplicate values.
  BAR(Y) uses the default value of X=1:M.  For vector inputs, BAR(X,Y)
  or BAR(Y) draws LENGTH(Y) bars.  The colors are set by the colormap.
  H = BAR(...) returns a vector of handles to barseries objects.
hb = bar(Y); % displays 5 barseries objects

create group

You create a group by parenting axes children to an hggroup or hgtransform object:

hg = hggroup;
set(hb,'Parent',hg) % parent the barseries to the hggroup

make it invisible

set(hg,'Visible','off') % makes all barseries invisible

make it visible again

set(hg,'Visible','on'); % turn it back on