Plot data sets with unique colors without using loop
古いコメントを表示
My existing code which produces the desired results is as follows,
for i = 1:k
cluster = data(V==i,:);
plot(cluster(:,1),cluster(:,2),'x');
end
'data' is a 1000x2 double array containing x and y coordinates. V is a 1000x1 integer array with values between 1 to k i.e. there are k subsets of data in total
I need to plot the different subsets in different colors which matlab automatically assigns because of individual calls to plot.
Is there a better way to code this without using a loop?
回答 (1 件)
Image Analyst
2017 年 12 月 4 日
That uses a color order, which is predefined and which will repeat. To get unique colors you'd have to pass in the color:
for i = 1:k
thisColor = rand(1, 3);
cluster = data(V==i,:);
plot(cluster(:,1), cluster(:,2), 'x', 'Color', thisColor, 'MarkerSize', 15);
end
カテゴリ
ヘルプ センター および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!