Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: colors for contour plots
Date: Wed, 23 Sep 2009 10:09:04 +0000 (UTC)
Organization: ErasmusMC
Lines: 34
Message-ID: <h9cs40$6up$1@fred.mathworks.com>
References: <h9ch1n$121$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1253700544 7129 172.30.248.35 (23 Sep 2009 10:09:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Sep 2009 10:09:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1095751
Xref: news.mathworks.com comp.soft-sys.matlab:572286


"Ernesto molina" <onka72@hotmail.com> wrote in message <h9ch1n$121$1@fred.mathworks.com>...
> 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
> 
> any help will be very appreciated
> Cheers
> Ernesto

As far as I know, you can only change the contour fill colour afterwards, not specify it while plotting.

Example using peaks:
[C,h] = contourf(peaks(20));
Cld = get(h, 'Children');
for j=1:length(Cld)
    if strcmp(get(Cld(j), 'Type'), 'patch')
        Iso = get(Cld(j), 'CData');
        if Iso<-5
            set(Cld(j), 'FaceColor', [1 0 0]);
        elseif Iso>=-5 && Iso<0
            set(Cld(j), 'FaceColor', [0 1 0]);
        elseif Iso>=0 && Iso<5
            set(Cld(j), 'FaceColor', [0 0 1]);
        else
            set(Cld(j), 'FaceColor', [0 1 1]);
        end
    end
end
    
Will this work for you?

Sebastiaan