Axes, Menus, and Toolbars in Programmatic UIs
hPlotAxes = axes(... % Axes for plotting the selected plot
'Parent', hMainFigure, ...
'Units', 'normalized', ...
'HandleVisibility','callback', ...
'Position',[0.11 0.13 0.80 0.67]);
- The axes function creates the axes. Setting the axes Parent property to
hMainFigure makes it a child of the main figure. - Setting the Units property to 'normalized' ensures that the axes resizes
proportionately when the user resizes the figure window. - The Position property is a 4-element vector that specifies the location of the axes
within the figure and its size: [distance from left, distance from bottom, width,
height].
The Pop-Up Menu
This command creates the pop-up menu:
hPlotsPopupmenu = uicontrol(... % List of available types of plot
'Parent', hMainFigure, ...
'Units','normalized',...
'Position',[0.11 0.85 0.45 0.1],...
'HandleVisibility','callback', ...
'String',mPlotTypes(:,1),...
'Style','popupmenu');
- The uicontrol function creates various user interface controls based on the value of
the Style property. Here, the Style property is set to 'popupmenu'. - For a pop-up menu, the String property defines the list of items in the menu. Here it
is defined as a 5-by-1 cell array of strings derived from the cell array mPlotTypes.
The Update Push Button
This command creates the Update push button:
hUpdateButton = uicontrol(... % Button for updating selected plot
'Parent', hMainFigure, ...
'Units','normalized',...
'HandleVisibility','callback', ...
'Position',[0.6 0.85 0.3 0.1],...
'String','Update',...
'Callback', @hUpdateButtonCallback);
- The uicontrol function creates various user interface controls based on the value
of the Style property. This statement does not set the Style property because its
default is 'pushbutton'.