Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simple plot question!!

Subject: Simple plot question!!

From: Hermano Cappa

Date: 27 Mar, 2011 00:01:04

Message: 1 of 3

Hi,

I have a 3D-plot of a sphere made with the surf-command. By default the color changes with the height of the data (z-direction --> color variation with the height of the sphere). How can I change the direction of this variation in color in such a way that when the data which is the furthest away form the origin (x-y-direction), thus at the equator, has a red color and the data which lies on x-y-axis has a blue color? Thus a variation in color that changes with the distance till an axis through the origin.

Subject: Simple plot question!!

From: Steven_Lord

Date: 27 Mar, 2011 19:46:47

Message: 2 of 3



"Hermano Cappa" <cappasteven@gmail.com> wrote in message
news:imluo0$r7q$1@fred.mathworks.com...
> Hi,
>
> I have a 3D-plot of a sphere made with the surf-command. By default the
> color changes with the height of the data (z-direction --> color variation
> with the height of the sphere). How can I change the direction of this
> variation in color in such a way that when the data which is the furthest
> away form the origin (x-y-direction), thus at the equator, has a red color
> and the data which lies on x-y-axis has a blue color? Thus a variation in
> color that changes with the distance till an axis through the origin.

http://www.mathworks.com/help/techdoc/ref/surf.html

"surf(X,Y,Z) creates a shaded surface using Z for the color data as well as
surface height." and

"surf(X,Y,Z,C) creates a shaded surface, with color defined by C."

[x,y,z] = peaks;
subplot(2, 1, 1);
surf(x, y, z, z); % color varies by z
subplot(2, 1, 2);
surf(x, y, z, x); % color varies by x

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Simple plot question!!

From: Hermano Cappa

Date: 27 Mar, 2011 21:09:05

Message: 3 of 3

"Steven_Lord" <slord@mathworks.com> wrote in message <imo45p$m7$1@fred.mathworks.com>...
>
>
> "Hermano Cappa" <cappasteven@gmail.com> wrote in message
> news:imluo0$r7q$1@fred.mathworks.com...
> > Hi,
> >
> > I have a 3D-plot of a sphere made with the surf-command. By default the
> > color changes with the height of the data (z-direction --> color variation
> > with the height of the sphere). How can I change the direction of this
> > variation in color in such a way that when the data which is the furthest
> > away form the origin (x-y-direction), thus at the equator, has a red color
> > and the data which lies on x-y-axis has a blue color? Thus a variation in
> > color that changes with the distance till an axis through the origin.
>
> http://www.mathworks.com/help/techdoc/ref/surf.html
>
> "surf(X,Y,Z) creates a shaded surface using Z for the color data as well as
> surface height." and
>
> "surf(X,Y,Z,C) creates a shaded surface, with color defined by C."
>
> [x,y,z] = peaks;
> subplot(2, 1, 1);
> surf(x, y, z, z); % color varies by z
> subplot(2, 1, 2);
> surf(x, y, z, x); % color varies by x
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Thank you very much Steve it works great! I thought it must be done with Clim but it is rather badly explained when you type 'help surf' in Matlab.

Tags for this Thread

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.

Contact us