How to vertically align a popupmenu uicontrol with an axes ?

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)

It is aligned, you just dont see it. I made a screenshoot of what i mean

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Asked:

on 23 Oct 2015

Edited:

on 14 Dec 2015

Community Treasure Hunt

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

Start Hunting!