-----Original Message-----

From:

[hidden email] [mailto:

[hidden email]] On Behalf Of Federica

Sent: Tuesday, May 31, 2011 11:45 AM

To:

[hidden email]
Subject: RE: different colours for different curves in the same plot

Thank you William!!!

So if I understand well, I need to define the color property for each line.

I followed your suggestion but I had no results.... an empty plot and all

the m values displayed.

The command

for m=1:length(ydata_sets)

refers to the range of values for m, is it right?

m values are between 0 and 1 so it becomes:

% start pseudo-code

plotColors = colormap;

figure

for m = 1:length(1)

plotColorsI = round( size( plotColors, 1)* m / length(1) );

hold on

plot(t,m);

H1 = plot(t, m)

hold off

set( H1,'Color', plotColors( plotColorsI,:) );

end

% end pseudo-code

And the result is an empty plot!!! What I did wrong??

maybe I need to define the number of lines?

Thank you again,

Federica

--

View this message in context:

http://octave.1599824.n4.nabble.com/different-colours-for-different-curves-in-the-same-plot-tp3563544p3563643.htmlSent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________

Help-octave mailing list

[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octaveFederica,

Sorry, I grabbed the wrong variable when I was cutting and pasting. In your code m is a non-integer value. In my psuedo-code m is meant to be an integer value. You can replace the variables in my code with any variable name to reduce confusion. Quick description for what I meant: If the y data is M sets of N values then m will step from 1 to M, and all N values associated with the mth set will be colored by the appropriate color. plotColorsI is just grabbing the integer index into the colormap that is defined by the ratio of mth set over total number of sets. If M is large with respect to the colormap size this will result in overlapping color designations.

Based upon the fact that you replaced the length of the y data columns value with length(1) in both places I think I may have misunderstood what you actually wanted to do.

What does size(m) return in your code before you rewrote my pseudo-code?

I rewrote the pseudo code to explicitly explain what I meant.

% start pseudo-code (that should run) rewritten to explain what I meant

xdata = 1:10;

ydata_sets = rand(4,10); % arbitrary definition

numberDataSets = size( ydata_sets,1 ); % used size instead to be explicit

m = ydata_sets(1,:); % this assumes that m is 1 vector from the parent set of vectors which is what I originally expected based upon your description

plotColors = colormap;

figure;

for nIndex = 1: numberDataSets

plotColorsI = round( size( plotColors, 1)* nIndex / numberDataSets );

hold on

H1 = plot( xdata, ydata_sets(nIndex,:) );

hold off

set( H1,'Color', plotColors( plotColorsI,:) );

end

% end pseudo-code

_______________________________________________

Help-octave mailing list

[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave