how can I plot scatterplot using scatter or gscatter with different color for each variable
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I am trying to plot some random variables(using gscatter and scatter) with different color
I also tried hsv for triplet RGB color for these functions,but it didn't work
could you please give me an instruction on how can I do that?
n = 200;
dat1=rand(n,1);
dat2=rand(n,1).*0.5;
dat3=-rand(n,1)*0.25;
0 件のコメント
採用された回答
Karim
2022 年 6 月 17 日
I'm not completly sure if I fully understand the question.
But the 4th input for the scatter command can be used to indicate the collor.
See the example code below, hope it helps:
n = 200;
dat1 = rand(n,1);
dat2 = rand(n,1)*0.50;
dat3 = -rand(n,1)*0.25;
x_data = repmat((1:n)',3,1); % assume some x-data
y_data = [dat1;dat2;dat3]; % gather the y-data
c_data = repelem([1;2;3],n); % generate the color indices
figure
scatter(x_data,y_data,[],c_data,'filled')
grid on
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!