Path: news.mathworks.com!not-for-mail
From: "Scott Frasso" <scott.frasso@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to insert textbox and write text in a figure by code (not manually)
Date: Thu, 16 Aug 2007 11:35:34 -0400
Organization: The Mathworks, Inc
Lines: 36
Message-ID: <fa1qs8$83n$1@fred.mathworks.com>
References: <fa1nue$lhh$1@fred.mathworks.com>
Reply-To: "Scott Frasso" <scott.frasso@mathworks.com>
NNTP-Posting-Host: frassos.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1187278536 8311 144.212.219.177 (16 Aug 2007 15:35:36 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Aug 2007 15:35:36 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:424166


Hello James,

% Create the figure
mFigure = figure()

% Create a uicontrol of type "text"
mTextBox = uicontrol('style','text')
set(mTextBox,'String','Hello World')

% To move the the Text Box around you can set and get the position of Text 
Box itself
mTextBoxPosition = get(mTextBox,'Position')
% The array mTextBoxPosition has four elements
% [x y length height]

% Something that I find useful is to set the Position Units to Characters, 
the default is pixels
set(mTextBox,'Units','characters')
% This means a Text Box with 3 lines of text will have a height of 3

-Scott

"James Anderson" <janderson_net@yahoo.com> wrote in message 
news:fa1nue$lhh$1@fred.mathworks.com...
> Hi,
>
> I want to insert a textbox in a given location of a figure
> and write some desciption in it, there is no edge in the
> textbox. I know how to do this manually, but don't know how
> to do this with script.
>
> Thanks,
>
> James