Explanation of "Position" in uitable

56 ビュー (過去 30 日間)
Shahar ben ezra
Shahar ben ezra 2021 年 5 月 9 日
編集済み: Adam Danz 2021 年 5 月 9 日
Hi
It is possible to get an explanation of the "Position" of the uitable function
I can not understand the meaning of the numbers
For example
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(Age,Height,Weight,'RowNames',LastName);
uitable('Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',[0, 0, 1, 1]);
% How do I set a location by:[0, 0, 1, 1]
or if i whant to do plot Next to a table
How can i do this by understanding the numbers like [0, 0, 1, 1]
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(Age,Height,Weight,'RowNames',LastName)
x = 0:pi/100:2*pi;
y = sin(x);
hAx=subplot(2,1,1);
hUI=uitable('Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',hAx.Position);
delete(hAx)
hAx=subplot(2,1,2);
plot(x,y)
TNX

採用された回答

Rik
Rik 2021 年 5 月 9 日
Since the units are set to Normalized, the units of the Position property are a percentage of the parent object (generally a figure or a panel).
If you go to the documentation for table and go to the Name,Value section, you can see links to two pages. Since you didn't specify using uifigure, I'll assume you're using a normal figure.
And here is the relevant documentation section:
"Location and size, specified as a four-element vector of the form [left bottom width height]."
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 5 月 9 日
Fractions rather than percentages.

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

その他の回答 (1 件)

Adam Danz
Adam Danz 2021 年 5 月 9 日
編集済み: Adam Danz 2021 年 5 月 9 日
The position and units property can be found on the Properties page of UITables
  1. Position property of uitables
  2. Units property of uitables (same link, scroll down)
Since you're setting units to normalized and position to [0 0 1 1] , the table should fill the whole container which in your case appears to be the figure window.
uitable(. . .,'units','normalize','position',[0 0 1 1])
This line below will only work if the axis units are also normalized and it will place the uitble directly on top of the axis.
uitable(. . .,'Units', 'Normalized', 'Position',hAx.Position)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by