Path: news.mathworks.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!newsswitch.lcs.mit.edu!newspump.monmouth.com!newspeer.monmouth.com!guardian.oit.duke.edu!news.glorb.com!news2.glorb.com!postnews.google.com!g23g2000vbr.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: colors for contour plots
Date: Thu, 24 Sep 2009 00:16:43 -0700 (PDT)
Organization: http://groups.google.com
Lines: 29
Message-ID: <a6c6ae68-5ae8-4977-89b5-9e6547cc938d@g23g2000vbr.googlegroups.com>
References: <h9ch1n$121$1@fred.mathworks.com>
NNTP-Posting-Host: 77.17.172.127
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1253776603 30374 127.0.0.1 (24 Sep 2009 07:16:43 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 24 Sep 2009 07:16:43 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: g23g2000vbr.googlegroups.com; posting-host=77.17.172.127; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; 
	.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:572514


On 23 Sep, 09:00, "Ernesto molina" <onk...@hotmail.com> wrote:
> hi there,
> I.m doing some contour plots (contourf) and I will llike to assign specific colors for value ranges....the colormap editor does not allow me to choose specificly that I want for example:
> dark red:        > +12.5m
> mid red:    +7.5 < X <= +12.5 m
> light red:     +2.5 m < X <= +7.5 m

First of all, set up a color map for the colors you want:

ncolors = 5;
cmap =zeros(ncolors,3);
cmap(:,1)=1;
cmap(:,2:3)=flipud((0:(ncolors-1))'*[1,1]/(ncolors-1));

Then plot the data with specified contour levels (note that
you need as many contour levens as colors in the color map):

data=rand(10);
contourf(data,[0,1,2]/3)

Last, activate the color map you made:

colormap(cmap)

And ther you are.

Rune