Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Multiple cdf plot and change color

Subject: Multiple cdf plot and change color

From: Skirt Zhang

Date: 2 Jun, 2011 13:21:05

Message: 1 of 3

Dear All,

I have a N*K matrix A and I want to get the cdf plot in one graph and change each colors. My code is below but I always get blue color for all.... Since I have more than 10 cdfs to plot it would be great if someone could help me with this in a loop method!!

THanks,

figure
  ColorSet = varycolor(K);
   
set(gcf, 'Colormap', ColorSet );


k=[1:1:K];
 

for i=1:K
    h(i)=cdfplot( betas(i,:) );
 
    hold on
end

Subject: Multiple cdf plot and change color

From: Steven_Lord

Date: 2 Jun, 2011 13:40:10

Message: 2 of 3



"Skirt Zhang" <silence_qunzi@hotmail.com> wrote in message
news:is82o1$qqc$1@newscl01ah.mathworks.com...
> Dear All,
>
> I have a N*K matrix A and I want to get the cdf plot in one graph and
> change each colors. My code is below but I always get blue color for
> all.... Since I have more than 10 cdfs to plot it would be great if
> someone could help me with this in a loop method!!

Try "hold all" instead of "hold on".

http://www.mathworks.com/help/techdoc/ref/hold.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Multiple cdf plot and change color

From: Grzegorz Knor

Date: 2 Jun, 2011 13:49:05

Message: 3 of 3

"Skirt Zhang" <silence_qunzi@hotmail.com> wrote in message <is82o1$qqc$1@newscl01ah.mathworks.com>...
> Dear All,
>
> I have a N*K matrix A and I want to get the cdf plot in one graph and change each colors. My code is below but I always get blue color for all.... Since I have more than 10 cdfs to plot it would be great if someone could help me with this in a loop method!!
>
> THanks,
>
> figure
> ColorSet = varycolor(K);
>
> set(gcf, 'Colormap', ColorSet );
>
>
> k=[1:1:K];
>
>
> for i=1:K
> h(i)=cdfplot( betas(i,:) );
>
> hold on
> end

Use SET function to change color of each line:

clr = jet(10);
hold on
for k = 1:10
y = evrnd(0,k,100,1);
h(k) = cdfplot(y);
set(h(k),'Color',clr(k,:))
end

best regards
Grzegorz

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us