function multi_colored_uitable
sampdata = randi(100,10,4);
markers = ' -.o';
colors = 'bgrm';
hfig = figure;hax = axes('position',[.1 .55 .8 .4]); hold on
for ind= 1:4
hplot(ind) = plot(sampdata(:,ind),['-' markers(ind) colors(ind)]);
end
for ind = 1:4
linecolor = 255*get(hplot(ind),'Color');
colorinhex = dec2hex(linecolor,2)';
marker = get(hplot(ind),'marker');
if strcmp(marker,'none')
marker=[];
end
linestyle = get(hplot(ind),'Linestyle');
linedata{1,ind} = colText([linestyle marker],['#' colorinhex(:)']);
end
tabledata = [linedata;mat2cell(sampdata,ones(1,10),ones(4,1))];
colnames = {'first', 'second', 'third', 'fourth'};
uitable(hfig, 'Data', tabledata, ...
'ColumnName', colnames, ...
'Units', 'normalized', ...
'Position', [.1 .05 .8 .4]);
end
function outHtml = colText(inText, inColor)
outHtml = ['<html><font color="',...
inColor, ...
'">', ...
inText, ...
'</font></html>'];
end
Best Answer