[uitable] Insert a table as a subplot
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Emmanouil Barmpounakis
el 28 de Abr. de 2015
Comentada: Joseph Cheng
el 28 de Abr. de 2015
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 comentarios
Respuesta aceptada
Joseph Cheng
el 28 de Abr. de 2015
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 comentarios
Joseph Cheng
el 28 de Abr. de 2015
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'})
Más respuestas (1)
Adam
el 28 de Abr. de 2015
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 comentarios
Adam
el 28 de Abr. de 2015
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.
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!