Table customization in figures

7 views (last 30 days)
Md Arif Ahmed Roni
Md Arif Ahmed Roni on 4 Mar 2022
Commented: daremo on 22 Mar 2024
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?

Answers (1)

Abhishek Chakram
Abhishek Chakram on 9 Oct 2023
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 Comment
daremo
daremo on 22 Mar 2024
Hi,
I think you can control the header of columns and rows by html code, have a look into the details with below link:

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!