How to color different variables in a scatter plot,

2 ビュー (過去 30 日間)
Arsal15
Arsal15 2016 年 2 月 16 日
コメント済み: Arsal15 2016 年 2 月 16 日
I am using Poisson distribution function to generate the number of variables each time I run the simulation and it generates randomly sometime 9, sometime 7 sometimes 11 and so on..
I want to color the data in scatter plot for all variables with different color for recognition of variables data. I used
if true
colormat = random(1,3);
end
but when i plot the scatter it gives error Index exceeds matrix dimensions. Can you guide me where I am doing mistake.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 2 月 16 日
random_values = YourPoisson_function(appropriate_parameters);
[unique_vals, ~, group_idx] = unique(random_values);
cmap = jet( length(unique_vals) ); %colormap with as many colors as groups
col_for_val = cmap(group_idx(:), :)); %index colormap by group number
x = 1 : length(random_values); %scatter plots are 2D, need some x
pointsize = 20;
scatter(x, random_values, pointsize, col_for_val);
  1 件のコメント
Arsal15
Arsal15 2016 年 2 月 16 日
Thanks for your comment. But you are grouping data set which are unique or common in all data set.
But I want to color the value of var1,var2,var3....var9 each with separate colors and each var1,var2 ... var9 having data set of [1x101] values.

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

カテゴリ

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