Path: news.mathworks.com!not-for-mail
From: "Ernesto molina" <onka72@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: colors for contour plots
Date: Thu, 24 Sep 2009 03:56:04 +0000 (UTC)
Organization: University of Tasmania
Lines: 73
Message-ID: <h9eqkk$s0h$1@fred.mathworks.com>
References: <h9ch1n$121$1@fred.mathworks.com> <h9cs40$6up$1@fred.mathworks.com> <h9d2gd$76h$1@fred.mathworks.com>
Reply-To: "Ernesto molina" <onka72@hotmail.com>
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 1253764564 28689 172.30.248.35 (24 Sep 2009 03:56:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 24 Sep 2009 03:56:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 867131
Xref: news.mathworks.com comp.soft-sys.matlab:572495


Thanks for that, I'm closer to get what a wanted but:
map =

         0         0    0.5608
         0    0.2510    1.0000
         0    1.0000    1.0000
    1.0000    1.0000    1.0000
    1.0000    0.3765         0
    1.0000         0         0
    0.7843         0         0
 
creating my 7 colors (range)
then colormap(map)
...[C,h] = contourf(long, time,'my variable');% my variable is 540x128
Cld = get(h, 'Children');
for j=1:length(Cld)
if strcmp(get(Cld(j),'Type'),'patch')
Iso=get(Cld(j),'CData');
if Iso > 12.5
set(Cld(j),'cdata',5);
elseif Iso >7.5&& Iso <= 12.5
set(Cld(j),'cdata',4);
elseif Iso >2.5&& Iso <= 7.5
set(Cld(j),'cdata',3);
elseif Iso >= -2.5 && Iso <= 2.5
set(Cld(j),'cdata',0);
elseif Iso < -2.5 && Iso >= -7.5
set(Cld(j),'cdata',1);
elseif Iso < -7.5 && Iso >= -12.5
set(Cld(j),'cdata',2);
elseif Iso < -12.5
end
end
end

..what I dont get is where you assign the color, I mean when doing set(Cld(j),'cdata', #).
I hope you understand my sort of explanation
cheers and thank you again
Ernesto
"Jerome Briot" <dut@matlab.fr> wrote in message <h9d2gd$76h$1@fred.mathworks.com>...
> > As far as I know, you can only change the contour fill colour afterwards, not specify it while plotting.
> > ...
> > Sebastiaan
> 
> The same solution but with a colormap :
> 
> figure
> 
> map = [1 0 0
>        0 1 0
>        0 0 1
>        0 1 1];
>    
> colormap(map);
> 
> [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), 'cdata', 0);
>         elseif Iso>=-5 && Iso<0
>             set(Cld(j), 'cdata', 1);
>         elseif Iso>=0 && Iso<5
>             set(Cld(j), 'cdata', 2);
>         else
>             set(Cld(j), 'cdata', 3);
>         end
>     end
> end
> 
> Jerome