How do I place a uitable in a subplot (MATLAB R2013a)?

조회 수: 9 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2016년 11월 21일
답변: MathWorks Support Team 2016년 11월 21일
I would like to place a uitable so that it fits exactly into one of the subplots in my figure. Is there a way to associate a uitable with a subplot?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2016년 11월 21일
There is no way to directly associate a uitable with a subplot, as uitable cannot be children of an axes. However, there is a simple workaround for this which involves saving the properties of the subplot.
The general idea is to create the subplot where you want the uitable to be located. Once the subplot is created, you can save the "Position" property of the subplot. This property contains both the location and the size of the axes. You can also save the units to ensure that the "Position" values are interpreted correctly.
Once these values are saved, you can delete the axes, and create a uitable using the same "Position" and "Unit" properties. This will ensure that the uitable has the same location and size as the subplot axes. For example, please try the following example code.
 
hf = figure;
ha = subplot(2,3,5);
pos = get(ha,'Position');
un = get(ha,'Units');
delete(ha)
ht = uitable('Units',un,'Position',pos)
This will create a uitable exactly where the subplot was first displayed. 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by