Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: I have n graphs and I want different color
Replies: 13   Last Post: Nov 9, 2012 2:41 PM

 Messages: [ Previous | Next ]
 Barry Williams Posts: 312 Registered: 6/14/06
Re: I have n graphs and I want different color
Posted: Nov 9, 2012 10:49 AM

"Steven_Lord" <slord@mathworks.com> wrote in message <k7j4ul\$nop\$1@newscl01ah.mathworks.com>...
>
>
> "Nasser M. Abbasi" <nma@12000.org> wrote in message
> news:k7imno\$df1\$1@speranza.aioe.org...

> > On 11/9/2012 4:29 AM, Nasser M. Abbasi wrote:
> >> On 11/9/2012 4:16 AM, Debora wrote:
>
> *snip*
>

>> *snip*
When I have to plot spectra, for example, that show an increase in response over time, I use a small program that I wrote to generate an array of colors that go from *cool* blue to *warm* red.

function Colors = plot_colors(no_plots)
% Generates an n X 3 array of rgb values for multiple plots.
% The colors trend from *coolor* blue to *warmer* red.
% This is useful for showing an increase in response over time.
% Can be used in a loop. Example:
% for n=1:no_plots
% plot(x(n), y(n), 'Color', Colors(n,:))
% end
%
Colors = zeros(no_plots,3);
Colors(:,1) = linspace(0,1,no_plots);
Colors(:,3) = linspace(1,0,no_plots);
half = round(no_plots/2);
Colors(1:half,2)=linspace(0,1,half);
Colors(half+1:no_plots,2)=linspace(1,0,no_plots-half);

I have found it useful for easily visualizing trends in the data where there are a maximum of about 20 plots.
Barry

Date Subject Author
11/9/12 Debora
11/9/12 Nasser Abbasi
11/9/12 Debora
11/9/12 Nasser Abbasi
11/9/12 Debora
11/9/12 Debora
11/9/12 Nasser Abbasi
11/9/12 Nasser Abbasi
11/9/12 Steven Lord
11/9/12 Barry Williams
11/9/12 Steven Lord
11/9/12 Debora
11/9/12 Nasser Abbasi
11/9/12 Debora