% parallel coordinate 3D cluster clf clear all npoints=50; %generate two clusters for i = 1:npoints/2; position(1,i)= randn; %x position(2,i)= randn ; %y position(3,i)= randn ; s(i)=1; end delta=5; for i = npoints/2+1:npoints; position(1,i)= randn+delta; %x position(2,i)= randn+delta ; %y position(3,i)= randn ; %y s(i)=2; end %color map map=jet(10) ; s = 10*(s - min(s))/(max(s)-min(s))+1 ; %========================================== % parallel cood subplot(2,1,1) hold on for i = 1:npoints cindex = min( fix(s(i)), 10); plot(position(:,i), 'color', map(cindex,:) ); % end %the axes axisx = [1,3; 1,1; 2,2; 3,3]'; axisy = [0,0; 0,1; 0,1; 0,1]'; line(axisx, axisy, 'color', 'k'); set(gca, 'xtick', [1 2 3]); set(gca, 'xticklabel', {'x1', 'x2','x3'}) %========================================== %normal space subplot(2,1,2) set(gca,'color',[1 1 1]) box on axis vis3d view(22,23) xlabel('x1'); ylabel('x2'); zlabel('x3'); hold on for i = 1:npoints cindex = min( fix(s(i)), 10); plot3(position(1,i),position(2,i),position(3,i),... 'markerfacecolor', map(cindex,:),... 'markersize',2 ,'color',map(cindex,:),... 'marker','o',... 'linewidth',2) line ( [position(1,i) position(1,i)],... [position(2,i) position(2,i)],... [position(3,i), -5] ,'color',map(cindex,:)) end set(gca,'zlim',[-5 5]) rotate3d on