Home how to scatter (or) plot group color matlab
Reply: 1

how to scatter (or) plot group color matlab

someone
1#
someone Published in 2014-03-21 05:57:17Z

I have the data matrix M size N by 3 where

M(:,1) and M(:,2) are the point represent in x,y axis and M(:,3) represent the group assign number

I try to use scatter plot that plot color differently according to the group assign

figure;
scatter(M(:,1) , M(:,2) , 3 ,?????? ,'fill');

I was confused to assign the group number into the color assignment by create another color representation group array C where C is matrix g by 3 ( g is a number of group and 3 represent color array element between 0-1)

I try ????? = C(M(:,3),:) but it didn't work

vipers36
2#
vipers36 Reply to 2014-03-21 08:48:11Z

What do you mean with didn't work? Do you get an error?

The code you suggested works for me:

C = [1 0 0;
     0 1 0;
     0 0 1];

M = [rand(10,2)  round(2*rand(10,1))+1];

figure(1);
scatter(M(:,1) , M(:,2) , 3, C(M(:,3),:) ,'fill');

Is it possible that somethings wrong with your C or M?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.332513 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO