Table customization in figures

7 次查看(过去 30 天)
Md Arif Ahmed Roni
评论: daremo 2024-3-22
Hello, I want to cutomize a table that i draw in a figure. I can change the font of the values, but not the font size of the column and row title. Also setting the column width as auto, doesnt fit when font size of the data is increased. i need to do this manually.
my code:
pos = get(tbl, 'Position');
un = get(tbl, 'Units');
uitable(h2, 'Data', T_tx1{:,:},...
'FontSize', 13,...
'ColumnWidth', {100,100,100},...
'ColumnName', T_tx1.Properties.VariableNames,...
'RowName', T_tx1.Properties.RowNames,...
'Units', un, 'Position', [pos(1) 2/3 (1-pos(1)) (1-2/3)]);
uitable(h2, 'Data', T_tx2{:,:},...
'FontSize', 13,...
'ColumnWidth', {100,100,100},...
'ColumnName', T_tx2.Properties.VariableNames,...
'RowName', T_tx2.Properties.RowNames,...
'Units', un, 'Position', [pos(1) 1/3 (1-pos(1)) (1-2/3)]);
Also is there any way to highlight the cells based on some criteria? like yellow, green or red? And control the decomal points of the values?

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2023-10-9
Hi Md Arif Ahmed Roni.
It is my understanding that you want to change the font size of the column and row titles and highlight a row based on some criteria. The ability to control the font size of “uitable” column and row title in MALTAB is not supported currently. However, you can highlight a row using “uistyle” and “addStyle” functions. Here is a sample code for the same:
s = uistyle("BackgroundColor","yellow");
for i=1:row % no. of rows
if i==2
addStyle(uit,s,"row",i);
end
end
You can refer to the following documentation to know more about the functions used:
Best Regards,
Abhishek Chakram
  1 个评论
daremo
daremo 2024-3-22
Hi,
I think you can control the header of columns and rows by html code, have a look into the details with below link:

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by