I am plotting 3d graph (X,Y,Z). I am unable to change color with the change of Y not Z (as default). Please help me.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de En. de 2019
Editada: Walter Roberson el 23 de En. de 2019

0 votos

You have two choices:
  1. Create an hgtransform group. When you scatter3() or surf(), or patch(), exchange the Y and Z parameters, and set the Parent of the plot to be the hgtransform group. Set the transform matrix of the hgtransform group to exchange the Y and Z axes. Note that if you take this approach, datatips might perhaps have Y and Z exchanged. This technique cannot be used with plot3() because plot3() does not offer any option to color by depth or by point.
  2. For surf() or patch(), pre-calculate the color you want each node to be according to whatever you choose, and set the CData property effectively to the image you texturemap on top of the surface or patch; warp() can make this process easier. For scatter3() pre-calculate the color you want each point to be according to whatever you choose, and pass the color in as the 5th argument (X, Y, Z, Pointsize, Color). This technique cannot be used with plot3() because plot3() does not offer any option to color by depth or by point.

5 comentarios

jamal
jamal el 23 de En. de 2019
Thank You Walter, I am a begginner of MATLAB. I will be very obliged if you give some randome example of this kind of plot.
Thank You again.
Walter Roberson
Walter Roberson el 23 de En. de 2019
Are you currently using scatter3() or plot3() or surface() or mesh() or patch() ?
jamal
jamal el 24 de En. de 2019
I am using surf(X,Y,Z).
Walter Roberson
Walter Roberson el 25 de En. de 2019
Then surf(X, Y, Z, Y) provided that Y is a 2D array the same size as Z.
If you are using marginal vectors for X and Y, then
[Xg, Yg] = meshgrid(X, Y);
surf(Xg, Yg, Z, Yg);
jamal
jamal el 26 de En. de 2019
Thanks Walter, Its working.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Object Containers en Centro de ayuda y File Exchange.

Preguntada:

el 21 de En. de 2019

Comentada:

el 26 de En. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by