Thread Subject: Customize colour in 3D graph

Subject: Customize colour in 3D graph

From: Bahari

Date: 3 Aug, 2009 21:31:01

Message: 1 of 10

Dear All,

I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.

Thanks

Bahari

Subject: Customize colour in 3D graph

From: Bahari

Date: 4 Aug, 2009 04:04:02

Message: 2 of 10

I used this matlab command:

[C,h] = contourf(X,Y,Z);
set(h,'ShowText','on'), colormap(gray(5))
text_handle = clabel(C,h);
set(text_handle,'BackgroundColor',[1 1 1],...
    'Edgecolor',[.7 .7 .7])

I can get very nice contour but the values is vary. I still can't control the colour. I want if the value of Z <1, the colour will be black and Z>=1, the colour will be white.

Anybody can help?

Thanks
Bahari
"Bahari " <baid69@yahoo.co.uk> wrote in message <h57kul$7p4$1@fred.mathworks.com>...
> Dear All,
>
> I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
>
> Thanks
>
> Bahari

Subject: Customize colour in 3D graph

From: Oliver Woodford

Date: 4 Aug, 2009 12:12:03

Message: 3 of 10

"Bahari " wrote:
> Dear All,
>
> I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
>
> Thanks
>
> Bahari

Use a separate color matrix:
C = Z >= 1;
C = double(im(:,:,[1 1 1]));
surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');

HTH,
Oliver

Subject: Customize colour in 3D graph

From: Bahari

Date: 5 Aug, 2009 01:50:18

Message: 4 of 10

Thanks Oliver, but it give me an error:

??? Undefined function or method 'im' for input arguments of type 'char'.
Error in ==> plot1 at 82
C=double(im(:,:,[1 1 1]));

How to solve this?

Regards

Bahari

"Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> "Bahari " wrote:
> > Dear All,
> >
> > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> >
> > Thanks
> >
> > Bahari
>
> Use a separate color matrix:
> C = Z >= 1;
> C = double(im(:,:,[1 1 1]));
> surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
>
> HTH,
> Oliver

Subject: Customize colour in 3D graph

From: Oliver Woodford

Date: 5 Aug, 2009 07:47:02

Message: 5 of 10

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5aogp$9mg$1@fred.mathworks.com>...
> Thanks Oliver, but it give me an error:
>
> ??? Undefined function or method 'im' for input arguments of type 'char'.
> Error in ==> plot1 at 82
> C=double(im(:,:,[1 1 1]));
>
> How to solve this?
>
> Regards
>
> Bahari
>
> "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> > "Bahari " wrote:
> > > Dear All,
> > >
> > > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> > >
> > > Thanks
> > >
> > > Bahari
> >
> > Use a separate color matrix:
> > C = Z >= 1;
> > C = double(im(:,:,[1 1 1]));
> > surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
> >
> > HTH,
> > Oliver

Change im to C.

Subject: Customize colour in 3D graph

From: Bahari

Date: 5 Aug, 2009 09:52:01

Message: 6 of 10

"Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h5bddm$4q8$1@fred.mathworks.com>...
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5aogp$9mg$1@fred.mathworks.com>...
> > Thanks Oliver, but it give me an error:
> >
> > ??? Undefined function or method 'im' for input arguments of type 'char'.
> > Error in ==> plot1 at 82
> > C=double(im(:,:,[1 1 1]));
> >
> > How to solve this?
> >
> > Regards
> >
> > Bahari
> >
> > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> > > "Bahari " wrote:
> > > > Dear All,
> > > >
> > > > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> > > >
> > > > Thanks
> > > >
> > > > Bahari
> > >
> > > Use a separate color matrix:
> > > C = Z >= 1;
> > > C = double(im(:,:,[1 1 1]));
> > > surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
> > >
> > > HTH,
> > > Oliver
>
> Change im to C.

It's work! Beside using surf I try to use contourf(X,Y,Z) because by using surf it just give me the point in rectangle. I think plot it by contourf is better. I tried to use the same way of surf but I still not success. Can you help me how to impliment this by using contourf.

Thanks in advanced.

Regards

Bahari

Subject: Customize colour in 3D graph

From: Bahari

Date: 5 Aug, 2009 10:15:07

Message: 7 of 10

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5bko1$ffd$1@fred.mathworks.com>...
> "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h5bddm$4q8$1@fred.mathworks.com>...
> > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5aogp$9mg$1@fred.mathworks.com>...
> > > Thanks Oliver, but it give me an error:
> > >
> > > ??? Undefined function or method 'im' for input arguments of type 'char'.
> > > Error in ==> plot1 at 82
> > > C=double(im(:,:,[1 1 1]));
> > >
> > > How to solve this?
> > >
> > > Regards
> > >
> > > Bahari
> > >
> > > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> > > > "Bahari " wrote:
> > > > > Dear All,
> > > > >
> > > > > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> > > > >
> > > > > Thanks
> > > > >
> > > > > Bahari
> > > >
> > > > Use a separate color matrix:
> > > > C = Z >= 1;
> > > > C = double(im(:,:,[1 1 1]));
> > > > surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
> > > >
> > > > HTH,
> > > > Oliver
> >
> > Change im to C.
>
> It's work! Beside using surf I try to use contourf(X,Y,Z) because by using surf it just give me the point in rectangle. I think plot it by contourf is better. I tried to use the same way of surf but I still not success. Can you help me how to impliment this by using contourf.
>
> Thanks in advanced.
>
> Regards
>
> Bahari

I used command below, it work but the color is not black and white to separate the value of Z, black for Z<1 and white for Z>=1. The color I have is blue for Z<1 and red for Z>=1.

C=Z>=1;
C=double(C(:,:,[1 1 1]));
contourf(X,Y,Z,C);

I think, I nearly there. Any body can help.

Regards

Bahari

Subject: Customize colour in 3D graph

From: Oliver Woodford

Date: 5 Aug, 2009 14:24:02

Message: 8 of 10

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5bm3b$hld$1@fred.mathworks.com>...
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5bko1$ffd$1@fred.mathworks.com>...
> > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h5bddm$4q8$1@fred.mathworks.com>...
> > > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5aogp$9mg$1@fred.mathworks.com>...
> > > > Thanks Oliver, but it give me an error:
> > > >
> > > > ??? Undefined function or method 'im' for input arguments of type 'char'.
> > > > Error in ==> plot1 at 82
> > > > C=double(im(:,:,[1 1 1]));
> > > >
> > > > How to solve this?
> > > >
> > > > Regards
> > > >
> > > > Bahari
> > > >
> > > > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> > > > > "Bahari " wrote:
> > > > > > Dear All,
> > > > > >
> > > > > > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Bahari
> > > > >
> > > > > Use a separate color matrix:
> > > > > C = Z >= 1;
> > > > > C = double(im(:,:,[1 1 1]));
> > > > > surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
> > > > >
> > > > > HTH,
> > > > > Oliver
> > >
> > > Change im to C.
> >
> > It's work! Beside using surf I try to use contourf(X,Y,Z) because by using surf it just give me the point in rectangle. I think plot it by contourf is better. I tried to use the same way of surf but I still not success. Can you help me how to impliment this by using contourf.
> >
> > Thanks in advanced.
> >
> > Regards
> >
> > Bahari
>
> I used command below, it work but the color is not black and white to separate the value of Z, black for Z<1 and white for Z>=1. The color I have is blue for Z<1 and red for Z>=1.
>
> C=Z>=1;
> C=double(C(:,:,[1 1 1]));
> contourf(X,Y,Z,C);
>
> I think, I nearly there. Any body can help.
>
> Regards
>
> Bahari

colormap(gray(256));

Subject: Customize colour in 3D graph

From: Bahari

Date: 5 Aug, 2009 14:24:02

Message: 9 of 10

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5bm3b$hld$1@fred.mathworks.com>...
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5bko1$ffd$1@fred.mathworks.com>...
> > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h5bddm$4q8$1@fred.mathworks.com>...
> > > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5aogp$9mg$1@fred.mathworks.com>...
> > > > Thanks Oliver, but it give me an error:
> > > >
> > > > ??? Undefined function or method 'im' for input arguments of type 'char'.
> > > > Error in ==> plot1 at 82
> > > > C=double(im(:,:,[1 1 1]));
> > > >
> > > > How to solve this?
> > > >
> > > > Regards
> > > >
> > > > Bahari
> > > >
> > > > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> > > > > "Bahari " wrote:
> > > > > > Dear All,
> > > > > >
> > > > > > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Bahari
> > > > >
> > > > > Use a separate color matrix:
> > > > > C = Z >= 1;
> > > > > C = double(im(:,:,[1 1 1]));
> > > > > surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
> > > > >
> > > > > HTH,
> > > > > Oliver
> > >
> > > Change im to C.
> >
> > It's work! Beside using surf I try to use contourf(X,Y,Z) because by using surf it just give me the point in rectangle. I think plot it by contourf is better. I tried to use the same way of surf but I still not success. Can you help me how to impliment this by using contourf.
> >
> > Thanks in advanced.
> >
> > Regards
> >
> > Bahari
>
> I used command below, it work but the color is not black and white to separate the value of Z, black for Z<1 and white for Z>=1. The color I have is blue for Z<1 and red for Z>=1.
>
> C=Z>=1;
> C=double(C(:,:,[1 1 1]));
> contourf(X,Y,Z,C);
>
> I think, I nearly there. Any body can help.
>
> Regards
>
> Bahari

Eureka! Lastly I can solve this problem by this comment:

C=Z>=1;
C=double(C(:,:,[1 1 1]));
contourf(X,Y,Z,C);
colormap gray

It give me black for Z <1 and white for Z >= 1.

Thanks a lot especially Oliver and the others.

Best Regards

Bahari

Subject: Customize colour in 3D graph

From: Bahari

Date: 9 Aug, 2009 13:47:01

Message: 10 of 10

"Bahari " <baid69@yahoo.co.uk> wrote in message <h5c4m2$9nm$1@fred.mathworks.com>...
> "Bahari " <baid69@yahoo.co.uk> wrote in message <h5bm3b$hld$1@fred.mathworks.com>...
> > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5bko1$ffd$1@fred.mathworks.com>...
> > > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h5bddm$4q8$1@fred.mathworks.com>...
> > > > "Bahari " <baid69@yahoo.co.uk> wrote in message <h5aogp$9mg$1@fred.mathworks.com>...
> > > > > Thanks Oliver, but it give me an error:
> > > > >
> > > > > ??? Undefined function or method 'im' for input arguments of type 'char'.
> > > > > Error in ==> plot1 at 82
> > > > > C=double(im(:,:,[1 1 1]));
> > > > >
> > > > > How to solve this?
> > > > >
> > > > > Regards
> > > > >
> > > > > Bahari
> > > > >
> > > > > "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <h598ij$k99$1@fred.mathworks.com>...
> > > > > > "Bahari " wrote:
> > > > > > > Dear All,
> > > > > > >
> > > > > > > I want to plot 3D graph. I used surf(X,Y,Z) and view from the Z axis (view(0,90)). The value of Z (height) shown n different colour to differentiate the height. How I can customize the colour so that the value of Z less than 1 will be black and more than 1 or 1 will be white.
> > > > > > >
> > > > > > > Thanks
> > > > > > >
> > > > > > > Bahari
> > > > > >
> > > > > > Use a separate color matrix:
> > > > > > C = Z >= 1;
> > > > > > C = double(im(:,:,[1 1 1]));
> > > > > > surf(X, Y, Z, C, 'edgecolor', 'none', 'facecolor', 'interp');
> > > > > >
> > > > > > HTH,
> > > > > > Oliver
> > > >
> > > > Change im to C.
> > >
> > > It's work! Beside using surf I try to use contourf(X,Y,Z) because by using surf it just give me the point in rectangle. I think plot it by contourf is better. I tried to use the same way of surf but I still not success. Can you help me how to impliment this by using contourf.
> > >
> > > Thanks in advanced.
> > >
> > > Regards
> > >
> > > Bahari
> >
> > I used command below, it work but the color is not black and white to separate the value of Z, black for Z<1 and white for Z>=1. The color I have is blue for Z<1 and red for Z>=1.
> >
> > C=Z>=1;
> > C=double(C(:,:,[1 1 1]));
> > contourf(X,Y,Z,C);
> >
> > I think, I nearly there. Any body can help.
> >
> > Regards
> >
> > Bahari
>
> Eureka! Lastly I can solve this problem by this comment:
>
> C=Z>=1;
> C=double(C(:,:,[1 1 1]));
> contourf(X,Y,Z,C);
> colormap gray
>
> It give me black for Z <1 and white for Z >= 1.
>
> Thanks a lot especially Oliver and the others.
>
> Best Regards
>
> Bahari

Hello!
Now I want to change the requirement: put label in every contour line and customize the color to if Z>=1 it will be light gray and Z<1 is white. I can't put black because we will not see the label at black area.
I tried below command:
[C,h] = contourf(x,y,z);
clabel(C,h,'FontSize',10,'Rotation',0);
colormap gray(2)

I can get the label but still can't customize the color. Any body can help?

Thanks

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
color Bahari 9 Aug, 2009 09:49:04
contourf Bahari 5 Aug, 2009 05:54:07
customize colour Bahari 3 Aug, 2009 17:34:02
surf Bahari 3 Aug, 2009 17:34:02
3d Bahari 3 Aug, 2009 17:34:02
rssFeed for this Thread

Contact us at files@mathworks.com