Path: news.mathworks.com!not-for-mail
From: "James Anderson" <janderson_net@yahoo.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 18:02:00 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 61
Message-ID: <fa23eo$rtk$1@fred.mathworks.com>
References: <fa1nue$lhh$1@fred.mathworks.com> <fa1qs8$83n$1@fred.mathworks.com>
Reply-To: "James Anderson" <janderson_net@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187287320 28596 172.30.248.37 (16 Aug 2007 18:02:00 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Aug 2007 18:02:00 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1069706
Xref: news.mathworks.com comp.soft-sys.matlab:424187


Scott,

Thanks for your reply, it works! One additional question is
that how to set the background color of the textbox to be
transparent as if there is no box frame, but still with
strings. 

I used the following command: 
set(mTextBox,'BackgroundColor',[1 1 1])
but don't know what's the corresponding 3 numbers for
transparent, or I should set some other properties instead
of background to do this? 

Many thanks,

James



"Scott Frasso" <scott.frasso@mathworks.com> wrote in message
<fa1qs8$83n$1@fred.mathworks.com>...
> 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 
> 
>