2D color plot with 3 vectors

30 vues (au cours des 30 derniers jours)
Zhiting
Zhiting le 28 Mar 2012
I have three vectors: x, y and z. Each (x(i), y(i)) coordinate corresponds to one z(i). I want to plot a 2D plot with x, y as axes and z denotes the colors. What should I do? Thanks a lot.

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Mar 2012
pointsize = 10;
scatter(x, y, pointsize, z)
  2 commentaires
Zhiting
Zhiting le 28 Mar 2012
Thanks a lot, Walter. This is what I want!
Riley Weatherholt
Riley Weatherholt le 23 Fév 2021
Thank you!! You just saved me a bunch of time.

Connectez-vous pour commenter.

Plus de réponses (3)

Richard
Richard le 28 Mar 2012
you could use pcolor(x,y,z). If you need further instruction let me know.
  2 commentaires
Zhiting
Zhiting le 28 Mar 2012
I have checked that before. z must be matrix in order to use pcolor. But I have three vectors. It doesn't work.
Walter Roberson
Walter Roberson le 28 Mar 2012
image() would be better than pcolor().
pcolor() and image() would assume that you have a full matrix of data, but the user only has vectors -- scattered points.

Connectez-vous pour commenter.


Thomas
Thomas le 28 Mar 2012
Just adding if you need a 3d graph:
dotsize=25
scatter3(x(:), y(:), z(:), dotsize, z(:), 'filled')
  1 commentaire
Zhiting
Zhiting le 28 Mar 2012
Thanks, Thomas~

Connectez-vous pour commenter.


SSth
SSth le 26 Oct 2017
How can I change color pattern.

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by