This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Why Are Some Components Missing or Partially Obscured?

Description of the Change

Axes, uicontrols or uitables might appear to be missing in the new graphics system because they are obscured by other components.

In previous releases, the order of components listed in the Children property matches the order in which they are created. However, this order does not necessarily match the front-to-back positioning (or the stacking order) of the components on the screen.

In previous releases, uicontrols always display on top of uipanels and uibuttongroups. Previous releases also allow an axes to display on top of a uipanel without being a child of the uipanel.

Starting in R2014b, the order of components listed in the Children property matches the stacking order of child components on the screen. You might need to update your code if your UI contains a uipanel or uibuttongroup:

  • Relative positioning is not sufficient to display an axes, uicontrol, or uitable on top of a uipanel or uibuttongroup. To place a component on top of another, set its Parent property to be the component you want to appear beneath it.

  • Uipanels and uibuttongroups have the same stacking order behavior on the screen as uicontrols and uitables.

The new behavior reflects changes to MATLAB® that provide more consistent behavior.

Restoring Programmatic Layouts

This code creates a figure with a top panel containing an axes and a bottom panel containing a push button and pop-up menu.

hf = figure;
hb = uicontrol('Style','PushButton',...
               'String','Plot',...
               'Position',[175, 40, 60, 25]);
hpulabel = uicontrol('Style','text',...
                     'String', 'Plot Type',...
                     'Position', [300, 65, 60, 20]);
hpu = uicontrol('Style', 'popupmenu',...
                'String', {'bar', 'plot', 'stem'},...
                'Position',[310, 40, 60, 25]);
topp = uipanel('Title', 'Plot',...
               'Position',[0 .25 1 .75]);
ah = axes('Position', [.10, .35 .80 .60]);
bottomp = uipanel('Title','Plotting Options',...
                  'Position',[0 0 1 .25]);
Running the code in previous releases produces the figure on the left. However, running this function in the new graphics system produces the figure on the right.

To ensure there are no components hidden behind containers, set the Parent property of each component to make it a child of the container. For example, the following code restores the original UI.

hf = figure;
topph = uipanel('Parent', hf,'Title', 'Plot',...
                'Position',[0 .25 1 .75]);
axes('Parent', topph, 'Position', [.10, .35 .80 .60]);
bottomph = uipanel('Parent', hf,'Title','Plotting Options',...
                   'Position',[0 0 1 .25])
hpulabel = uicontrol('Parent', bottomph, 'Style','text',...
                     'String', 'Plot Type',...
                     'Position', [300, 65, 60, 20]);
hb = uicontrol('Parent', bottomph, 'Style','PushButton',...
               'String','Plot',...
               'Position',[175, 40, 60, 25]);
hpu = uicontrol('Parent', bottomph, 'Style', 'popupmenu',...
                'String', {'bar', 'plot', 'stem'},...
                'Position',[310, 40, 60, 25]);

Restoring GUIDE Layouts

Restoring the layout of a GUIDE UI requires two separate steps:

  • Fix the layout in GUIDE.

  • Fix the child order of the components.

To fix the layout in GUIDE, open the fig-file in GUIDE and use the Send to back option to rearrange the stacking. For example, to move the panel in this layout behind all other components, right-click the panel and select Send to back.

To fix the child order of the components, so that they display the same as in GUIDE, select View > Object Browser. Then, select a component and move it slightly within the panel or button group. For example, selecting and moving this Start button slightly while it is on the panel makes it a child of the panel.

Child components display on top of their parent, so this Start button displays on top of the panel when the program runs.

Related Topics