필터 지우기
필터 지우기

[uitable] Insert a table as a subplot

조회 수: 26 (최근 30일)
Emmanouil Barmpounakis
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'.

채택된 답변

Joseph Cheng
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
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 4월 28일
편집: Emmanouil Barmpounakis 2015년 4월 28일
Yes, Joseph I would like a click and drag ability as you describe in your reply.
If this is not possible, I would be OK if I could give a title to this table and also a name to columns and rows (like the title,xlabel and ylabel properties for a figure).
Thank you for your time.
Joseph Cheng
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
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
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 4월 28일
편집: Emmanouil Barmpounakis 2015년 4월 28일
I am sorry but I can not understand what you suggest.
As I write in a comment below, if moving the table is not possible, I would be OK if I could give a title to this table and also a name to columns and rows (like the title,xlabel and ylabel properties for a figure).
Any ideas on that? Thank you for your time.
Adam
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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by