MATLAB Answers

Title for each table in one figure

14 ビュー (過去 30 日間)
Anna Sergeeva
Anna Sergeeva 2019 年 11 月 12 日
コメント済み: Anna Sergeeva 2019 年 11 月 12 日
Hi
I have a figure, where I have four tables. I could make a title for the hole figure, but I would like to make a title for each table. I have tried with uicontrol, where I have tried to make a text field with title, but I couldn't make it work. I have an example in the code for the first table. Someone can help? Sorry for the long code :-)
%% Bonferroni-Holm correction for ASSR amplitude
alpha = zeros(15,1);
n = 15;
for m = 1:15
alpha(m) = 0.05/n;
n = n-1;
end
fig = uifigure;
fig.Position = [0 440 1280 400];
VarName = {'PT' '1/6 oct' '1/3 oct' '1/2 oct' '1 oct' '2 oct'};
set(fig,'Name','Paired T-test: ASSR Amplitude, left upper: ipsilateral without BH correction, left lower: ipsilateral with BH correction , right upper: contralateral without BH correction, right lower: contralateral with BH correction');
% for amplitude for ipsilateral measurements without Bonferroni-Holm correction
p_amp_il_cor = unique(sort(p_amp_il(:)));
p_amp_il_cor(isnan(p_amp_il_cor)) = [];
T_il = array2table(p_amp_il,'VariableNames', VarName, 'RowNames', VarName);
uit11 = uitable(fig);
uit11.Data = T_il;
uit11.Position = [20 220 600 158];
% c = uicontrol('Style','text', 'Position', [20 380 600 10], 'String', 'ipsilateral without BH correction' );
% uicontrol(c);
s = uistyle('BackgroundColor','white');
addStyle(uit11,s);
styleIndices = ismissing(T_il);
[row,col] = find(styleIndices);
s = uistyle('BackgroundColor',[0.9 0.9 0.9], 'Fontcolor', [0.9 0.9 0.9]);
addStyle(uit11,s,'cell',[row,col]);
s = uistyle('Fontcolor', 'red');
for i = 1:size(p_amp_il,1)
for l =1:size(p_amp_il,2)
if p_amp_il(i,l) < 0.05
addStyle(uit11,s,'cell', [i,l])
end
end
end
% for amplitude for ipsilateral measurements with Bonferroni-Holm correction
uit21 = uitable(fig);
uit21.Data = T_il;
uit21.Position = [20 40 600 158];
s = uistyle('BackgroundColor','white');
addStyle(uit21,s);
styleIndices = ismissing(T_il);
[row,col] = find(styleIndices);
s = uistyle('BackgroundColor',[0.9 0.9 0.9], 'Fontcolor', [0.9 0.9 0.9]);
addStyle(uit21,s,'cell',[row,col]);
s = uistyle('Fontcolor', 'red');
for i = 1:size(p_amp_il,1)
for l =1:size(p_amp_il,2)
if ~isnan(p_amp_il(i,l))
elem = find(p_amp_il_cor == p_amp_il(i,l));
if p_amp_il_cor(elem) < alpha(elem)
addStyle(uit21,s,'cell', [i,l])
end
end
end
end
% for amplitude for contralateral measurements without Bonferroni-Holm correction
p_amp_cl_cor = unique(sort(p_amp_cl(:)));
p_amp_cl_cor(isnan(p_amp_cl_cor)) = [];
T_cl = array2table(p_amp_cl,'VariableNames', VarName, 'RowNames', VarName);
uit12 = uitable(fig);
uit12.Data = T_cl;
uit12.Position = [660 220 600 158];
s = uistyle('BackgroundColor','white');
addStyle(uit12,s);
styleIndices = ismissing(T_cl);
[row,col] = find(styleIndices);
s = uistyle('BackgroundColor',[0.9 0.9 0.9], 'Fontcolor', [0.9 0.9 0.9]);
addStyle(uit12,s,'cell',[row,col]);
s = uistyle('Fontcolor', 'red');
for i = 1:size(p_amp_cl,1)
for l =1:size(p_amp_cl,2)
if p_amp_il(i,l) < 0.05
addStyle(uit12,s,'cell', [i,l])
end
end
end
% for amplitude for contralateral measurements with Bonferroni-Holm correction
uit22 = uitable(fig);
uit22.Data = T_cl;
uit22.Position = [660 40 600 158];
s = uistyle('BackgroundColor','white');
addStyle(uit22,s);
styleIndices = ismissing(T_cl);
[row,col] = find(styleIndices);
s = uistyle('BackgroundColor',[0.9 0.9 0.9], 'Fontcolor', [0.9 0.9 0.9]);
addStyle(uit22,s,'cell',[row,col]);
s = uistyle('Fontcolor', 'red');
for i = 1:size(p_amp_il,1)
for l =1:size(p_amp_cl,2)
if ~isnan(p_amp_cl(i,l))
elem = find(p_amp_cl_cor == p_amp_cl(i,l));
if p_amp_cl_cor(elem) < alpha(elem)
addStyle(uit22,s,'cell', [i,l])
end
end
end
end

  0 件のコメント

サインインしてコメントする。

採用された回答

dpb
dpb 2019 年 11 月 12 日
Whole lot of code to wade through but the first little bit is just
N = 15;
Alpha0=0.05;
alpha=Alpha0./(N:-1:1);
I don't do GUIs as a rule so this is a bit just from the examples, but seems simple enough...
hUIfig = uifigure;
hUIfig.Position = [0 440 1280 400];
hUIt1 = uitable(hUIfig,'Data',randi(100,10,3),'Position',[20 20 260 204]);
hUILbl1=uilabel(hUIfig,'Text','Table 1','Position',[40 234 260 20]),'horizontalalign','center');
creates a uifigure and a table at a given position. A label above it at an arbitrary adjusted position vector seems to work quite nicely; you would want to compute the location of the text probably as the midpoint of the table position xy and a pleasing distance above; I fudged a little to try to come closer to above the data columns instead of the overall table. It didn't quite work out that way, but the idea should be all you need it would seem.

  1 件のコメント

Anna Sergeeva
Anna Sergeeva 2019 年 11 月 12 日
Thank you very much!!!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by