Borrar filtros
Borrar filtros

Fitting a uitable to a subplot

9 visualizaciones (últimos 30 días)
Jason
Jason el 23 de Dic. de 2016
Comentada: Emily Pitts el 28 de Jul. de 2022
Hi. I want to programatically add a uitable to a subplot position (without using guide). Whilst I have been able to do this, Im not able to fill the subplot region. Is it possible to do this (at least in the horizontal dimension)
This is my code:
% create the data
% Create the column and row names in cell arrays
cnames = {'Z','FMc','FMc','AvgI'};
rnames = {'1','2','3','4','5','6','7','8'};
% Create the uitable
t = uitable(f1,'Data',data,...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{50});
subplot(1,2,2),plot(3)
pos = get(subplot(1,2,2),'position');
delete(subplot(1,2,2))
set(t,'units','normalized')
set(t,'position',pos)
I was wondering if the ColumnWidth variable could somehow be calculated from the subplot width?

Respuesta aceptada

Jan
Jan el 26 de Dic. de 2016
% Auto-resize:
jScroll = findjobj(t);
jTable = jScroll.getViewport.getView;
jTable.setAutoResizeMode(jTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
drawnow;
  4 comentarios
Jan
Jan el 23 de Ag. de 2017
@Spencer G: You are right, there is not auto-resizing of rows. I've found some links about auto-resizing of tables vertically:
But I do not have time to implement this in Matlab currently.
Emily Pitts
Emily Pitts el 28 de Jul. de 2022
I've been looking for a solution to this for days, and your solution worked perfectly in MATLAB 2022a. Thanks!

Iniciar sesión para comentar.

Más respuestas (1)

M E
M E el 29 de Jun. de 2018
This one might also be useful: How do I place a uitable in a subplot

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by