How to vertically align a popupmenu uicontrol with an axes ?

10 views (last 30 days)
I am trying to vertically align an axes containing text and a popup menu uicontrol as in the following example :
F = figure('Units','normalized','Position',[0.5 0.5 0.3 0.2]);
position = [0.1 0.5 0.3 0.3];
a = axes('Position', position,...
'Visible', 'off',...
'Parent', F);
text(0,0.5,'My text','Units','Normalized')
hpop = uicontrol('Parent', F,...
'Style', 'popupmenu',...
'Units', 'Normalized',...
'Position', [position(1)+0.4 position(2:4)],...
'Enable', 'on',...
'String' , {'Choice 1','Choice 2'});
align([a,hpop],'none','middle')
The text is intentionally vertically centered in the axes to facilitate the vertical alignment with the popup menu. I used an axes with the text function to display text since the text uicontrol can not be centered vertically. Running this script returns the figure below. Setting the 'Visible' property of the axes to 'on' shows that the axes and the popup menu aren't centered vertically either.

Answers (1)

Turangga Lazuardi
Turangga Lazuardi on 14 Dec 2015
Edited: Turangga Lazuardi on 14 Dec 2015
It is aligned, you just dont see it. I made a screenshoot of what i mean

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!