how can i display on a table's cell different colors ?
26 views (last 30 days)
Show older comments
Stephani Kanga on 11 Nov 2020
Commented: Stephani Kanga on 16 Nov 2020
I read the rgb values from an excel file and I want to show the color in a uitable cell.
I tried addStyle but it only works for uifigure while i'm working on figure and i also tried to change the background of the cell but the background changes for all the cells of the table. Is there a way to change the color of a specific cell ?
Eric Sofen on 12 Nov 2020
It sounds like you're on the right track. You want to apply the addStyle to the uitable, not the uifigure:
fig = uifigure;
fig.Position = [500 500 520 200];
uit = uitable(fig);
uit.Data = rand(5);
uit.Position = [20 30 480 135];
% add some color
s1 = uistyle('BackgroundColor','r');
s2 = uistyle('BackgroundColor','b');
addStyle(uit,s2,'cell',[1 1; 2 4; 3 5;])
Find more on Develop uifigure-Based Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!