フィルターのクリア

How can i create a color vector for markers in a scatter plot?

3 ビュー (過去 30 日間)
Bernt Milne
Bernt Milne 2011 年 6 月 1 日
I have two vectors X,Y. I would like to make a scatter plot scatter(x,y,s,c), but i don't have a C vector. So my quaestion is, how can i make a C-vector with the same lenght as my other vecotrs in such a way that i get the right color settings on my plot.

回答 (1 件)

Arnaud Miege
Arnaud Miege 2011 年 6 月 1 日
It depends what you mean by the "right colour settings". The following will give you a C matrix of the right size, but whether that's the colour settings you expect, it's another question:
C = rand(length(x),3);
scatter(x,y,s,C); % where x, y and s are already defined
Arnaud
  2 件のコメント
Bernt Milne
Bernt Milne 2011 年 6 月 1 日
Thank you for your reply. What i ment was that i want the color of the dots to represent the number of points with a given size(Y) and postition(X). Do you know how to do that?
Arnaud Miege
Arnaud Miege 2011 年 6 月 1 日
I think you can do one or the other but not both at the same time. The following will colour the scatter plot based on the number of point with a certain y:
load seamount
n = hist(y,length(x));
scatter(x,y,5,n)

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

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by