3
votes

I would like to display several tables in the same MATLAB figure, much the same as subplot can be used to display multiple graphs. However, it seems that subplot does not apply to uitable objects.

Failed attempt

As you can see, instead of five tables distributed across the figure, I am getting five sets of empty axes, and only one of the tables is visible.

Is there a way to do this in MATLAB?

EDIT: Much better after applying the answer supplied below!

enter image description here

1

1 Answers

1
votes

The parent of a uitable is a figure or uipanel itself. So, you can use the tables units and position properties to manually set the tables position within the figure or uipanel. If t is the handle to a table created by t=uitable(...) then you can use set(t,'units'...) and set(t,'position',[left buttom widht height]) to position the table appropriately.

Here is a specific example

f=figure
dd=rand(5,4); %# data
colnames = {'1' '2' '3' 'weight'}
for i=1:4
    t(i) = uitable(f,'columnname',colnames, ...
                     'data',dd, ...
                     'units','normalized', ...
                     'pos',[(i-1)/4 0 .25 1])
end