[uitable] Insert a table as a subplot
26 ビュー (過去 30 日間)
古いコメントを表示
Emmanouil Barmpounakis
2015 年 4 月 28 日
コメント済み: Joseph Cheng
2015 年 4 月 28 日
I am trying to insert an 8x8 table next to an existing plot. Although both of them appear in the same figure(4), the table cannot be moved or edited, therefore I cannot illustrate the results as I want to.
The code I use is provided below:
f=figure(4)
% create the data
d = od_table;
% Create the column and row names in cell arrays
cnames = {'1','2','3','4','5','6','7','8'};
rnames = {'1','2','3','4','5','6','7','8'};
% Create the uitable
t = uitable(f,'Data',d,...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{30})
The ideal solution for me would the table to be able to be moved around the figure with fixed size, titles etc. As a 'movable legend'.
0 件のコメント
採用された回答
Joseph Cheng
2015 年 4 月 28 日
I'm not entirely sure what you are describing as the ideal solution. Are you asking for a click and drag ability to dynamically move and resize items? I can't think of something right off the bat for how to accomplish that but if you want to move and resize the uitable you can do something like this
f=figure(4)
% create the data
% Create the column and row names in cell arrays
cnames = {'1','2','3','4','5','6','7','8'};
rnames = {'1','2','3','4','5','6','7','8'};
% Create the uitable
t = uitable(f,'Data',rand(8),...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{30})
subplot(2,1,1),plot(3)
pos = get(subplot(2,1,2),'position');
delete(subplot(2,1,2))
set(t,'units','normalized')
set(t,'position',pos)
Where i get and set the uitable to fit inside subplot(2,1,2) position.
2 件のコメント
Joseph Cheng
2015 年 4 月 28 日
well not the cleanest way but
f=figure(4)
% create the data
% Create the column and row names in cell arrays
cnames = {'1','2','3','4','5','6','7','8'};
rnames = {'1','2','3','4','5','6','7','8'};
% Create the uitable
t = uitable(f,'Data',rand(8),...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{30})
subplot(2,1,1),plot(3)
pos = get(subplot(2,1,2),'position');
title('table')
xlabel('xlabel')
ylabel('ylabel')
set(subplot(2,1,2),'yTick',[])
set(subplot(2,1,2),'xTick',[])
set(t,'units','normalized')
set(t,'position',pos)
set(t,'ColumnName',{'a','b','c','d','e','f','g','h'})
set(t,'RowName',{'aa','bb','cc','dd','ee','ff','gg','hh'})
その他の回答 (1 件)
Adam
2015 年 4 月 28 日
There is a ColumnEditable property that is set to be off for all columns by default. You need to set it to a logical vector with an element per column to get editable columns.
In terms of moving it around I'm not really sure what you mean. In the 'arrow' mode on a figure ( 'Edit plot' as the tooltip says ) you can drag a table around just like you can other components if you select it.
4 件のコメント
Adam
2015 年 4 月 28 日
column are row names are already a part of uitable. A title can be given just by a text control if you wish.
Being able to drag a UI component around without clicking on the relevant toolbar button in the figure to put you in that mode is not possible as far as I am aware though.
Obviously you could program it yourself using the Mouse move callback and ButtonDown callback etc, but that is not at all trivial.
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!