Colors in UI tables
There are two color options available with UI tables in MATLAB, foreground and background. We shall see them both in the following example.
We can change the background and foreground colors by using the ‘BackGround’ and ‘ForeGround’ options respectively and then, passing their respective RGB values following them both. The background changes the color of cells whereas the foreground changes the color of font. See the following example for better understanding.
Example 8:
Matlab
% Code uif = uifigure; age = [32 ;23; 15; 17; 19]; names = { 'Howard' ; 'Harry' ; 'Mark' ; 'Nik' ; 'Mike' }; gen = { 'M' ; 'M' ; 'M' ; 'F' ; 'M' }; tab = table(age,names,gen); tab = uitable(uif, 'BackgroundColor' ,[1 1 0], 'ForegroundColor' ,[0 0.4470 0.7410], 'Data' ,tab); |
Here, we change the background to yellow and the foreground (font color) to navy blue color using their respective RGB values.
Output:
As it can be seen, the cell color is yellow, and the font color is a shade of blue.
Control Table UI Component Appearance and Behavior in MATLAB
In this article, we shall discuss how to create UI tables in MATLAB and control their behaviors and appearance by manipulating some basic properties and visuals. UI tables in MATLAB are the graphical form of tabular data. The UI tables can be created using the uitable function.
Syntax
tab = uitable(…parameters…)
The uitable without any parameters generates an empty table. Different parameters could be passed to the same for data modification. We shall not discuss creating UI tables in depth as it is not in this article’s scope.