Heatmap in uipanel resizing in normal mode but not when debugging

조회 수: 3 (최근 30일)
Old Newbie
Old Newbie 2025년 8월 11일
답변: Old Newbie 2025년 8월 11일
Hi,
I have created a grid layout ([3,2]) in a tab in a programmatical app. The column width for the grid layout is set to 'fit' for both columns. In the first row, I have a uitable and a uiaxes next to each other and in the second row, I have a uipanel and another uiaxes next to one another. The final row contains a button.
The content of the uipanel in the second row, is a heatmap based on the correlations between variables. I am using a uipanel as a parent since heatmap cannot be the child of uiaxes.
When I debug the code, the heatmap fills the uipanel perfectly and everything runs as expected. However, if I remove the breakpoints and run the code in normal mode, the heatmap resizes for some reason and becomes very small in the uipanel.
This is the code used to create the gridlayout:
g3=uigridlayout(tab3,[3 2]);
g3.RowHeight = {'fit','fit','fit'};
g3.ColumnWidth = {'fit','fit'};
testdata=array2table(zeros(13,4),"RowNames",variables,"VariableNames",{'Variable 1','Variable 2','Variable 3','Variable 4'});
t14=uitable(g3,"Data",testdata);
t14.ColumnEditable = repelem(false,4);
t14.Layout.Row=1;
t14.Layout.Column=1;
s1=uistyle(HorizontalAlignment='right');
addStyle(t14,s1);
ax1=uiaxes(g3);
ax1.Layout.Row=1;
ax1.Layout.Column=2;
ax_heat=uipanel(g3);
ax_heat.Layout.Row=2;
ax_heat.Layout.Column=1;
ax_box=uiaxes(g3);
ax_box.Layout.Row=2;
ax_box.Layout.Column=2;
The heatmap is calculated and assigned to the uipanel as follows:
R=corr(Data);
hm=heatmap(ax_heat,variables, variables,R,'Colormap',jet);
  1. Is there a way to "force" the size of the heatmap to fill the entire uipanel?
  2. Why is the behaviour different between debugging (perfect) and normal mode?
Thanks in advance!

답변 (1개)

Old Newbie
Old Newbie 2025년 8월 11일
I managed to "fix" this by switching the auto resizing of children off:
ax_heat=uipanel(g3);
ax_heat.Layout.Row=2;
ax_heat.Layout.Column=1;
ax_heat.AutoResizeChildren = 'off';
I don't know why that worked as I would have thought that it would be better to have that switched on.
Also, I still don't know why the debugging seems to prevent the resizing from occurring.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by