필터 지우기
필터 지우기

Save a Uitable with coloured cells as as png.

조회 수: 4 (최근 30일)
Alessandro Togni
Alessandro Togni 2021년 4월 28일
답변: Adam Danz 2021년 4월 28일
Hi, i've created a Uitable object and colured its cells with this code:
app.UITable.Data=CreateUITable(app, app.deltas_table, app.deltas_threshold);
%% GUI TABLE COLOURING (ANALYSIS MODULE)
% Hightlight over-threshold values in red
[redRows, redCols]= find( abs(app.UITable.Data{:,2}) >= app.deltas_threshold);
z = uistyle('BackgroundColor',[1 0.6 0.6]);
addStyle(app.UITable, z ,'cell',[redRows, redCols]);
addStyle(app.UITable, z ,'cell',[redRows, redCols+1]);
addStyle(app.UITable, z ,'cell',[redRows, redCols+2]);
addStyle(app.UITable, z ,'cell',[redRows, redCols+3]);
% Hightlight under-threshold values in green
[greenRows, greenCols]= find( abs(app.UITable.Data{:,2}) <= app.deltas_threshold);
n = uistyle('BackgroundColor',[0.6 1 0.6]);
addStyle(app.UITable, n ,'cell', [greenRows, greenCols]);
addStyle(app.UITable, n ,'cell',[greenRows, greenCols+1]);
addStyle(app.UITable, n ,'cell',[greenRows, greenCols+2]);
addStyle(app.UITable, n ,'cell',[greenRows, greenCols+3]);
% Hightlight NaN values in gray
NaNidxs = ismissing(app.UITable.Data);
[NaNrow,NaNcol] = find(NaNidxs);
s = uistyle('BackgroundColor',1/255*[200,200,200]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol+1]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol+2]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol+3]);
Now i want to save the table on a .png (or pdf) file.
Any help would be really appreciated.
Alessandro

답변 (1개)

Adam Danz
Adam Danz 2021년 4월 28일
One solution is to put the uitable within a uipanel and then use exportgraphics to export the table.
If you want to export the entire figure you don't need to embed the table within a panel.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by