writing a table into a subplot of a figure
조회 수: 9 (최근 30일)
이전 댓글 표시
I would like to create a figure with a few subplots, at least one of these being a data table to show the statistics (mean, st. dev., st. err.) of some measurements in the plots.
How do I write a table into a figure? I have tried fprintf, disp, sprintf, all of which write into the workspace, and I have tried text which is good for writing something, but not necessarily the organization of a table. Sometimes numbers will be big and other times they will be small, so using the text command becomes complicated in laying out the table and having it fit into the subplot.
Is there a function for a table? Is there an easier way to do it with text? Can I have a table without figure axes?
댓글 수: 0
채택된 답변
추가 답변 (2개)
Matthew
2012년 5월 11일
I recently worked this out for my personal case - UITABLE is great, but did not give me the look I wanted. Here is what I did:
NOTE: Using Courier is good for the justification issues to get text aligned.
% Convert to text
intCellString = cell([size(sub_rmsint_tab,1) 1]);
for ii = 1:size(sub_rmsint_tab,1)
thisRow = [];
for jj = 1:size(sub_rmsint_tab,2)
if isnan(sub_rmsint_tab(ii,jj))
thisRow = [thisRow ' '];
else
%thisRow = [thisRow sprintf('%7.0f',sub_rmsint_tab(ii,jj))];
thisRow = [thisRow sprintf('%7.0f\t',sub_rmsint_tab(ii,jj))];
end
end
intCellString{ii,1} = thisRow;
end
% Convert to text
depCellString = cell([size(sub_dep_tab,1) 1]);
for ii = 1:size(sub_dep_tab,1)
thisRow = [];
for jj = 1:size(sub_dep_tab,2)
thisRow = [thisRow sprintf('%7.0f\t',sub_dep_tab(ii,jj))];
end
depCellString{ii,1} = thisRow;
end
x = -3;
y = -5;
subplot(1,3,3)
myBigTable = [{' From Semblance Analysis'};...
{' TWTT Depth TWTT bsf Depth bsf Vint Vrms'};...
intCellString; {' '};{' '};{' '};...
{' From Refraction Modeling'};...
{' TWTT Depth TWTT bsf Depth bsf Vint Vrms'}; ...
depCellString];
t1 = text(x,y,myBigTable);
set(t1,'fontname','courier')
set(t1,'fontsize',6)
set(t1,'HorizontalAlignment','left')
Brad
2012년 5월 17일
댓글 수: 4
Norman Koren
2013년 3월 1일
It worked well for me when I used a well-formed HTML expression:
'Δ'
But frustrating that it's inconsistent with the rest of Matlab and not well documented (I'd be out of luck if it weren't for this post).
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!