Path: news.mathworks.com!not-for-mail
From: "Keith Gould" <kbgould@wisc.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Changing color of specific text in a textbox?
Date: Tue, 4 Aug 2009 18:42:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 23
Message-ID: <h59vdt$ich$1@fred.mathworks.com>
Reply-To: "Keith Gould" <kbgould@wisc.edu>
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 1249411325 18833 172.30.248.37 (4 Aug 2009 18:42:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 4 Aug 2009 18:42:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1899108
Xref: news.mathworks.com comp.soft-sys.matlab:560790


This will either be really simple, or practically impossible.  So lets say I have the following code...

str1=strcat('SD=', randomVar1);
str2=strcat('zscore=', randomVar2);
str3=strcat('R^2=', randomVar3);
set(textBox, 'String', [str1, char(10), str2, char(10), str3], 'BackgroundColor', [1 1 1], 'Position', [.84 .105 .135 sizestat], 'FontSize', 8, 'HorizontalAlignment', 'left');

This will create some textbox on my figure that will look sort of like this (presuming my text doesn't get mangled):
--------------------------------
|   SD=X.XXX             |
|   zscore=-X.XXX       |
|   R^2=X.XXX           |
--------------------------------

and of course, presume that I have some numerical values for randomVar1, 2 and 3... they've been represented as X.XXX or -X.XXX.

Since it's really hard to see the negative sign in the figure I would like to add colors to certain portions of the text in the textbox, but not all of it.  Ideally, I want to color green for positive and red for negative values.

So im wondering if its possible to color a certain portion of the text such as just the "SD=X.XXX" section?

Thanks for any help in advance!!

-Keith