-
Notifications
You must be signed in to change notification settings - Fork 2
/
spread_gui.m
34 lines (31 loc) · 801 Bytes
/
spread_gui.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function spread_gui(hax, X, label)
% Plot samples of different labels with different colors.
[d,n] = size(X);
if nargin == 2
label = ones(n,1);
end
assert(n == length(label));
color = 'brgmcyk';
m = length(color);
c = max(label);
switch d
case 2
view(2);
for i = 1:c
idc = label==i;
scatter(hax, X(1,idc),X(2,idc),36,color(mod(i-1,m)+1));
end
case 3
view(3);
for i = 1:c
idc = label==i;
scatter3(hax, X(1,idc),X(2,idc),X(3,idc),36,color(mod(i-1,m)+1)); hold on;
end
hold on; [x,y,z] = sphere;
surface(x,y,z,'FaceColor', 'none'); hold off;
otherwise
error('ERROR: only support data of 2D or 3D.');
end
axis equal
grid on
hold off