Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Barry Williams

Posts: 309
Registered: 6/14/06
Re: I have n graphs and I want different color
Posted: Nov 9, 2012 10:49 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.