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: Sun, 19 Aug 2007 10:54:42 -0400
Organization: The Mathworks, Inc
Lines: 84
Message-ID: <fa9ljk$bjq$1@fred.mathworks.com>
References: <fa1nue$lhh$1@fred.mathworks.com> <fa1qs8$83n$1@fred.mathworks.com> <fa23eo$rtk$1@fred.mathworks.com>
Reply-To: "Scott Frasso" <scott.frasso@mathworks.com>
NNTP-Posting-Host: frassos.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1187535284 11898 144.212.219.177 (19 Aug 2007 14:54:44 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 19 Aug 2007 14:54:44 +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:424474


Jeff,

<how to set the background color of the textbox to be
transparent as if there is no box frame, but still with
strings.>

You can set the background color of the Text Box to the same color as the 
Figure window by getting the figure windows "Color" value and applying it to 
the "BackgroundColor" of the Text Box.

% Get the Color of the figure window
colorOfFigureWindow = get(mFigure,'Color');

%Set the BackgroundColor of the text box
set(mTextBox,'BackgroundColor',colorOfFigureWindow)

-Scott


"James Anderson" <janderson_net@yahoo.com> wrote in message 
news:fa23eo$rtk$1@fred.mathworks.com...
> 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
>>
>>
>