How can I produce different colours for different clusters?

조회 수: 4 (최근 30일)
Hi,
I have the following dataset --> three columns (x,y, class of the data point(0,1,2,3 or 4)).
(-9.69171, -8.86384, 0)
(-9.55902, -8.10946, 0)
(-1.73544, -7.12043, 1)
(-1.77755, -6.39318, 1)
(-3.79288, -5.00445, 2)
(-3.36182, -6.39692, 2)
(-1.46405, -1.70081, 3)
(-0.413965, -2.22041, 3)
(-9.59192, -8.78982, 4)
(-9.72115, -8.37142, 4)
(This is just a sample dataset)
How can I plot that dataset where each data point has the same colour of its label. (The data is labelled in four groups).
Thank you

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 16일
pointsize = 30;
scatter(x(:), y(:), pointsize, group_number+1);
colormap(jet(5))
  댓글 수: 6
Abdulatif Alabdulatif
Abdulatif Alabdulatif 2016년 5월 17일
편집: Abdulatif Alabdulatif 2016년 5월 17일
Great!
1- How can I plot from 1 to 100 in separate scatter with a specific symbol?
Thanks
Walter Roberson
Walter Roberson 2016년 5월 18일
symbols = {'*', '+', '.', 'v', 'p'};
for idx = 1 : length(symbols)
mask = group_number == idx;
scatter(x(mask), y(mask), pointsize, 'Marker', symbols{idx});
hold on
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by