uitable overlaps a white panel in a traditional figure

3 Ansichten (letzte 30 Tage)
Olga Dimov
Olga Dimov am 12 Okt. 2017
Kommentiert: Olga Dimov am 19 Okt. 2017
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.

Akzeptierte Antwort

David Ding
David Ding am 18 Okt. 2017
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

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by