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일

0 개 추천

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:

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

릴리스

R2021b

태그

질문:

2022년 3월 4일

댓글:

2024년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by