COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Problem with colorbar

• Email
• Follow

```I am using matlab 2010. I want to draw a colorbar on contourf plot but the contourf colors and colorbar colors are not matching
The example code looks like this
clear; clc;close all;
X=1:10;Y=1:10;
C=rand(10,10)*100;
colormap(jet(7));
[c1 h1]=contourf(X,Y,C,fliplr([0 10 20 50 60 70 100]));
clabel(c1,h1);
colorbar

I want to say if the values 20-50 fall in one category then why 20-30 30-40 is displayed on the colorbar
```
 0
Reply Makarand 5/19/2010 10:45:23 AM

See related articles to this posting

```I think no body could understand my problem
I shall make it more brief please answer it.
I modify the code like this
clear; clc;close all;
X=1:10;Y=1:10;
C=rand(10,10)*100;
colormap(jet(7));
[c1 h1]=contourf(X,Y,C,fliplr([0 10 20 50 60 70]));
clabel(c1,h1);
hold on
pcolor(X,Y,C);
colorbar

See the Pcolr values are not matching with the matrix C why is so?
```
 0
Reply Makarand 5/19/2010 11:39:05 AM

```"Makarand " <makarand_kulkarni@hotmail.com> wrote in message <ht0fg3\$li7\$1@fred.mathworks.com>...
> I am using matlab 2010. I want to draw a colorbar on contourf plot but the contourf colors and colorbar colors are not matching
> The example code looks like this
> clear; clc;close all;
> X=1:10;Y=1:10;
> C=rand(10,10)*100;
> colormap(jet(7));
> [c1 h1]=contourf(X,Y,C,fliplr([0 10 20 50 60 70 100]));
> clabel(c1,h1);
> colorbar
>
> I want to say if the values 20-50 fall in one category then why 20-30 30-40 is displayed on the colorbar

Kindly check little modified code
clear; clc;close all;
X=1:10;Y=1:10;
C=rand(10,10)*100;
colormap(jet(7));
[c1 h1]=contourf(X,Y,C,fliplr([0 10 20 50 60 70]));
clabel(c1,h1);
hold on
pcolor(X,Y,C);
colorbar

see the values in the matrix C doesn't agree with the color scale what to do for that
```
 0
Reply Makarand 5/19/2010 11:44:04 AM

```"Makarand " <makarand_kulkarni@hotmail.com> wrote in message <ht0fg3\$li7\$1@fred.mathworks.com>...
> I am using matlab 2010. I want to draw a colorbar on contourf plot but the contourf colors and colorbar colors are not matching
> The example code looks like this
> clear; clc;close all;
> X=1:10;Y=1:10;
> C=rand(10,10)*100;
> colormap(jet(7));
> [c1 h1]=contourf(X,Y,C,fliplr([0 10 20 50 60 70 100]));
> clabel(c1,h1);
> colorbar
>
> I want to say if the values 20-50 fall in one category then why 20-30 30-40 is displayed on the colorbar

I do not understand your problem but
It seems your problem is colorbar.

why not you set the colorbar.
```
 0
Reply mat001 5/19/2010 2:09:06 PM

```"mat001 " <priya.biomath@yahoo.co.in> wrote in message <ht0re2\$pon\$1@fred.mathworks.com>...
> "Makarand " <makarand_kulkarni@hotmail.com> wrote in message <ht0fg3\$li7\$1@fred.mathworks.com>...
> > I am using matlab 2010. I want to draw a colorbar on contourf plot but the contourf colors and colorbar colors are not matching
> > The example code looks like this
> > clear; clc;close all;
> > X=1:10;Y=1:10;
> > C=rand(10,10)*100;
> > colormap(jet(7));
> > [c1 h1]=contourf(X,Y,C,fliplr([0 10 20 50 60 70 100]));
> > clabel(c1,h1);
> > colorbar
> >
> > I want to say if the values 20-50 fall in one category then why 20-30 30-40 is displayed on the colorbar
>
> I do not understand your problem but
> It seems your problem is colorbar.
>
> why not you set the colorbar.

hi ,
Thanks for the reply
Will you please tell me how to do that?
Because you see we have 7 categories of contour and 7 colors, but some colors remain unused. and some have been used twice. so how to handle this problem.
thanks again
```
 0
Reply Makarand 5/20/2010 3:04:05 AM

4 Replies
396 Views

Similar Articles

12/7/2013 11:21:41 AM
[PageSpeed]