Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to change color for multiple data sets plotted on one graph
Date: Mon, 17 Dec 2012 00:55:08 +0000 (UTC)
Organization: Ohio State University
Lines: 41
Message-ID: <kalqhc$i9h$1@newscl01ah.mathworks.com>
References: <kadrne$ibm$1@newscl01ah.mathworks.com> <kae1ct$6fn$1@newscl01ah.mathworks.com> <kafhtk$rht$1@speranza.aioe.org>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1355705708 18737 172.30.248.46 (17 Dec 2012 00:55:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 17 Dec 2012 00:55:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3627291
Xref: news.mathworks.com comp.soft-sys.matlab:784923

dpb <none@non.net> wrote in message <kafhtk$rht$1@speranza.aioe.org>...
> On 12/13/2012 8:03 PM, Greg Heath wrote:
> > "Natasha" wrote in message <kadrne$ibm$1@newscl01ah.mathworks.com>...
> >> I have a script that allows you to change one variable manually. Each
> >> time you do so and plot the outcome, a new line forms. How can I make
> >> it so that each new line is a new color (or alternating colors)?
> >>
> >> What I have: figure (1)
> >> plot(r,w1)
> >>
> >>
> >> I'm very new to matlab, and teaching myself. I've tried several codes
> >> involving 'color' but do not know how to write it properly, any help
> >> would be appreciated.
> >
> > figure(2)
> > hold on
> > plot(x,y1,'b')
> > plot(x,y2,'g')
> > plot(x,y3,'r')
> > etc
> >
> > Hope this helps. Also see
> >
> > help plot
> >
> > doc plot
> ...
> 
> And, to make it slightly more general, make up a colors vector of the 
> entries in the predefined list
> 
> colors={'b';'g';'r'; ... };  % fill in rest of list in lieu of ...
> plot(x,y(i),colors{i})       % i is a variable index in your loop, say
> 
> NB since colors is cell array, use the {} to dereference it.  Or, it 
> could be a character array since is one character, but if then wanted to 
> add a line character to be more than a single character have to address 
> it as the 2D array instead of the single cell index.
> 
> Thank you so much.