MATLAB Answers

0

From 2014 to 2015 Matlab Versions I am now unable to display my annotation textbox in a uipanel. How can I display it on top of the uipanel?

Asked by Ranjit Kaur on 11 Aug 2015
Latest activity Commented on by Mike Garrity
on 11 Aug 2015
I used an annotation textbox which was displayed in a uipanel in version 2014 now in 2015 it can not be displayed in the uipanel. Is there a way of getting round this? I am also using a textbox becuase I need to display the text in a particular format(underscores). Using uicontrol you are unable to do this. Also the annotation textbox you are unable to specify Parent it is not part of the properties list.

  1 Comment

annotation(handle,...) creates the annotation in the figure, uipanel, or uitab specified by handle.

Sign in to comment.

1 Answer

Answer by Mike Garrity
on 11 Aug 2015
 Accepted Answer

It sounds like it's probably this issue.
In earlier releases of MATLAB, the panel didn't really honor stacking/containment correctly because it was drawn into the wrong graphics layer. That was fixed in R2014b. You now need to parent things to the panel if you don't want them to be obscured by the panel.
Consider this example:
p = uipanel('Position',[.25 .25 .5 .5])
a1 = annotation(p,'textbox');
a1.String = {'This text string','is inside the panel'};
a1.HorizontalAlignment = 'center';
a1.Position = [.5 .3 .7 .2];
a2 = annotation(gcf,'textbox');
a2.String = {'This text string','is outside of','the panel'};
a2.HorizontalAlignment = 'center';
a2.Position = [.3 .7 .5 .2];

  2 Comments

Great thank you this works fine. In Matlab help it does not specify how you the parent for the annotation textbox or for any annotation should be written writing 'Parent', p does not work. Cheers. Ranjit
Yeah, the help could be clearer. If you do 'doc annotation' instead of 'help annotation', you'll get a bit more detail about the 1st arg, but even that doesn't have a good example.

Sign in to comment.