Display multiple uitable objects in the same figure?

江枫思渺然 提交于 2019-12-23 16:47:35

问题


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.

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!


回答1:


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


来源:https://stackoverflow.com/questions/10438402/display-multiple-uitable-objects-in-the-same-figure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!