Borrar filtros
Borrar filtros

colormap using plot3

109 visualizaciones (últimos 30 días)
Mike Lee
Mike Lee el 11 de Mzo. de 2017
Editada: Stephen23 el 11 de Mzo. de 2017
Hi, I have a plot like this below. Is there any way to put a colormap so the color changes by only Z value?

Respuestas (2)

KSSV
KSSV el 11 de Mzo. de 2017
Use scatter3 instead of plot3. Read about scatter3.

Stephen23
Stephen23 el 11 de Mzo. de 2017
Editada: Stephen23 el 11 de Mzo. de 2017
If you plotting those points as one line, then the answer is no: one line, one color.
Some alternatives:
  • plot multiple lines.
  • use scatter3.
  • use surf or mesh (depending on how your data is arranged).
  • use this FEX submission: cline.
Personally I think using scatter3 is your best option, because this probably represents your data organization:
>> [X,Y,Z] = peaks(64);
>> scatter3(X(:),Y(:),Z(:),30,Z(:))
  2 comentarios
Mike Lee
Mike Lee el 11 de Mzo. de 2017
But I would like refine the shape like below later. Is this still possible by using scatter?
Stephen23
Stephen23 el 11 de Mzo. de 2017
Editada: Stephen23 el 11 de Mzo. de 2017
I no idea what "refine the shape" means. "refine" is not a mathematical operation that I know. If you are going to change the plotted data or make a new plot and want to control the color range, then read about the caxis.
I have no idea what data you have, how it is structured, and how it correlates to the two seemingly unrelated plots that you have shown. But probably the answer to your question "Is this still possible by using scatter?" is yes.

Iniciar sesión para comentar.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by