Thread Subject: coloring contour plot

Subject: coloring contour plot

From: Bahari

Date: 10 Aug, 2009 11:16:03

Message: 1 of 7

Dear All,
I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
I succeed to plot the contour with the label as command below but still not success to coloring it.

[C,h]=contour(X,Y,Z);
clabel(C,h,'FontSize',10,'Rotation',0);
colormap gray

Thanks in advance for help.

Bahari

Subject: coloring contour plot

From: Amin Bashi

Date: 10 Aug, 2009 12:44:03

Message: 2 of 7

Bahari
try this, userdata value is value of isolines of matrix Z
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[X,Y] = meshgrid(-2:.2:2,-2:.2:3);
Z = X.*exp(-X.^2-Y.^2);
[C,h] = contour(X,Y,Z);
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
h3 = findall(0,'userdata',-0.2,'type','patch')
set(h3,'EdgeColor',[0 0 0])


"Bahari " <baid69@yahoo.co.uk> wrote in message <h5ovhi$jug$1@fred.mathworks.com>...
> Dear All,
> I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
> I succeed to plot the contour with the label as command below but still not success to coloring it.
>
> [C,h]=contour(X,Y,Z);
> clabel(C,h,'FontSize',10,'Rotation',0);
> colormap gray
>
> Thanks in advance for help.
>
> Bahari

Subject: coloring contour plot

From: Bahari

Date: 10 Aug, 2009 13:12:03

Message: 3 of 7

Thanks Amin Bashi.

I tried your example but seem not as I expected. The background of contour is black, the label is white and the isoline is colorfull.
I'm not sure what wrong.

Regards

Bahari

"Amin Bashi" <matlabedu.ir.nospam@gmail.com> wrote in message <h5p4mj$i9b$1@fred.mathworks.com>...
> Bahari
> try this, userdata value is value of isolines of matrix Z
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> [X,Y] = meshgrid(-2:.2:2,-2:.2:3);
> Z = X.*exp(-X.^2-Y.^2);
> [C,h] = contour(X,Y,Z);
> set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
> h3 = findall(0,'userdata',-0.2,'type','patch')
> set(h3,'EdgeColor',[0 0 0])
>
>
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5ovhi$jug$1@fred.mathworks.com>...
> > Dear All,
> > I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
> > I succeed to plot the contour with the label as command below but still not success to coloring it.
> >
> > [C,h]=contour(X,Y,Z);
> > clabel(C,h,'FontSize',10,'Rotation',0);
> > colormap gray
> >
> > Thanks in advance for help.
> >
> > Bahari

Subject: coloring contour plot

From: Lorenzo Guerrasio

Date: 10 Aug, 2009 13:27:02

Message: 4 of 7

You could simply create your colormap and than load it everytime you make a figure.

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5ovhi$jug$1@fred.mathworks.com>...
> Dear All,
> I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
> I succeed to plot the contour with the label as command below but still not success to coloring it.
>
> [C,h]=contour(X,Y,Z);
> clabel(C,h,'FontSize',10,'Rotation',0);
> colormap gray
>
> Thanks in advance for help.
>
> Bahari

Subject: coloring contour plot

From: Bahari

Date: 10 Aug, 2009 14:07:03

Message: 5 of 7

Thanks a lot, could you pls give an example to create my own colormap. If I can reverse the colormap gray, I think, a little bit I can solve my problem.

Another things, I found this from matlab Help:
"[C,h,CF] = contourf(...) returns the contour matrix C as calculated by the function contourc and used by clabel, a vector of handles h to patch graphics objects (instead of a contourgroup object, for compatibility with MATLAB Version 6.5 and earlier) and a contour matrix CF for the filled areas."

I think this command can help me to solve my problem but how to use this "[C,h,CF] = contourf(...)" I'm not so understand. Any one can help?

Regards

Bahari


"Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <h5p776$8pl$1@fred.mathworks.com>...
> You could simply create your colormap and than load it everytime you make a figure.
>
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5ovhi$jug$1@fred.mathworks.com>...
> > Dear All,
> > I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
> > I succeed to plot the contour with the label as command below but still not success to coloring it.
> >
> > [C,h]=contour(X,Y,Z);
> > clabel(C,h,'FontSize',10,'Rotation',0);
> > colormap gray
> >
> > Thanks in advance for help.
> >
> > Bahari

Subject: coloring contour plot

From: Lorenzo Guerrasio

Date: 10 Aug, 2009 14:32:03

Message: 6 of 7

there should be several example in help colormap.

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5p9i7$9gc$1@fred.mathworks.com>...
> Thanks a lot, could you pls give an example to create my own colormap. If I can reverse the colormap gray, I think, a little bit I can solve my problem.
>
> Another things, I found this from matlab Help:
> "[C,h,CF] = contourf(...) returns the contour matrix C as calculated by the function contourc and used by clabel, a vector of handles h to patch graphics objects (instead of a contourgroup object, for compatibility with MATLAB Version 6.5 and earlier) and a contour matrix CF for the filled areas."
>
> I think this command can help me to solve my problem but how to use this "[C,h,CF] = contourf(...)" I'm not so understand. Any one can help?
>
> Regards
>
> Bahari
>
>
> "Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <h5p776$8pl$1@fred.mathworks.com>...
> > You could simply create your colormap and than load it everytime you make a figure.
> >
> > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5ovhi$jug$1@fred.mathworks.com>...
> > > Dear All,
> > > I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
> > > I succeed to plot the contour with the label as command below but still not success to coloring it.
> > >
> > > [C,h]=contour(X,Y,Z);
> > > clabel(C,h,'FontSize',10,'Rotation',0);
> > > colormap gray
> > >
> > > Thanks in advance for help.
> > >
> > > Bahari

Subject: coloring contour plot

From: Bahari

Date: 10 Aug, 2009 21:55:22

Message: 7 of 7

Thanks Lorenzo Guerrasio,

This is my solution for this moment:
[C,h]=contourf(X,Y,Z);
clabel(C,h,'FontSize',20,'Rotation',0);
caxis([0.5 1])
colormap gray

I think this is not a good solution but it work. What I done, after run the program I reverse the colormap manual. So I get what I want.

If anybody now how to reverse the colormap gray, let me know.

Any way, thanks for everybody.

Regards

Bahari

"Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <h5pb13$nnp$1@fred.mathworks.com>...
> there should be several example in help colormap.
>
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5p9i7$9gc$1@fred.mathworks.com>...
> > Thanks a lot, could you pls give an example to create my own colormap. If I can reverse the colormap gray, I think, a little bit I can solve my problem.
> >
> > Another things, I found this from matlab Help:
> > "[C,h,CF] = contourf(...) returns the contour matrix C as calculated by the function contourc and used by clabel, a vector of handles h to patch graphics objects (instead of a contourgroup object, for compatibility with MATLAB Version 6.5 and earlier) and a contour matrix CF for the filled areas."
> >
> > I think this command can help me to solve my problem but how to use this "[C,h,CF] = contourf(...)" I'm not so understand. Any one can help?
> >
> > Regards
> >
> > Bahari
> >
> >
> > "Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <h5p776$8pl$1@fred.mathworks.com>...
> > > You could simply create your colormap and than load it everytime you make a figure.
> > >
> > > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5ovhi$jug$1@fred.mathworks.com>...
> > > > Dear All,
> > > > I want to color my contour base on value of Z, if Z<=1 the color will be white and if Z>1 the color will be light gray.
> > > > I succeed to plot the contour with the label as command below but still not success to coloring it.
> > > >
> > > > [C,h]=contour(X,Y,Z);
> > > > clabel(C,h,'FontSize',10,'Rotation',0);
> > > > colormap gray
> > > >
> > > > Thanks in advance for help.
> > > >
> > > > Bahari

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
colormap Lorenzo Guerrasio 10 Aug, 2009 09:29:07
coloring Bahari 10 Aug, 2009 07:19:02
contourf Bahari 10 Aug, 2009 07:19:02
contour Bahari 10 Aug, 2009 07:19:02
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com