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.

 採用された回答

Walter Roberson
Walter Roberson 2012 年 3 月 28 日

6 投票

pointsize = 10;
scatter(x, y, pointsize, z)

2 件のコメント

Zhiting
Zhiting 2012 年 3 月 28 日
Thanks a lot, Walter. This is what I want!
Riley Weatherholt
Riley Weatherholt 2021 年 2 月 23 日
Thank you!! You just saved me a bunch of time.

サインインしてコメントする。

その他の回答 (3 件)

Richard
Richard 2012 年 3 月 28 日

1 投票

you could use pcolor(x,y,z). If you need further instruction let me know.

2 件のコメント

Zhiting
Zhiting 2012 年 3 月 28 日
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 2012 年 3 月 28 日
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.

サインインしてコメントする。

Thomas
Thomas 2012 年 3 月 28 日

0 投票

Just adding if you need a 3d graph:
dotsize=25
scatter3(x(:), y(:), z(:), dotsize, z(:), 'filled')

1 件のコメント

Zhiting
Zhiting 2012 年 3 月 28 日
Thanks, Thomas~

サインインしてコメントする。

SSth
SSth 2017 年 10 月 26 日

0 投票

How can I change color pattern.

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by