uitable overlaps a white panel in a traditional figure
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello! I would like to display a table in a traditional figure. My script is simple:
%******
f = figure('Name', 'My table', 'Position', [1000 500 1000 500];
ut = uitable(f, 'Data', dat, 'Position', [20 20 950 450]);
hold on
%******
However, when I run my script, the figure shows up with the table and looks good, but when I maximize the figure, I can see a white panel (grid) underneath the table and the table partially covers the grid. How do I get rid of the white panel under the table?
Thank you.
****************************
Update: I figured out that the grid shows up because I have a title line:
title('Numbers', 'FontSize', 12);
I guess my new question is: is it possible to add a title to a table without the grid showing up? Also I would like to add labels to rows and columns to explain what rows and columns mean.
Thank you.
채택된 답변
David Ding
2017년 10월 18일
Hi Olga,
I understand that when you have a uitable in a figure and you maximize the window for the figure, a "grid" shows up that is partly behind the uitable. Thank you for sharing the code. I was able to reproduce the issue with the code you shared.
It turns out that the issue is not because of the title, but rather, because the position of the figure in the window is independent of the uitable, such that when you maximize the window, the figure position gets misaligned with that of the uitable. In order to fix this, do not explicitly set the position of the figure.
As for title, Currently, the "uitable" does not have a "Title" property that can be set. However, you can achieve the desired effect by placing a "uicontrol" of style "text" directly above the uitable.
Putting everything together, below is an example of a uitable in figure with title text that does not have the observed issue when you maximize the window:
f = figure;
t = uitable(f);
d = {'Male',52,true;'Male',40,true;'Female',25,false};
t.Data = d;
t.Position = [20 20 258 78];
t.ColumnName = {'Gender','Age','Authorized'};
txt_title = uicontrol('Style', 'text', 'Position', [20 100 200 20], 'String', 'My Example Title');
Thanks,
David
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!