matlab で scatter3 プロットを使用して、大量の特徴を持つデータ セットを視覚化するにはどうすればよいですか。PCA を使用して既に 3 つの機能に減らしていますが、対応する行の y 値 (またはラベル付きの値) が 1 か 0 かによって異なる色で表示するにはどうすればよいですか? PS PCA は [675 x 3] 行列を返します。これは、データ セット内の 675 の例であり、最初の 3 つの主成分を含みます。
2 に答える
2
% Create some data to represent the results of PCA
x = rand(675,3); y = randi([0,1],675,1);
% Plot with markers of size 10
scatter3(x(:,1),x(:,2),x(:,3),10,y)
他の場所で提案されているループおよび if ステートメントのアプローチよりも少し簡単です。
于 2012-05-11T08:42:00.100 に答える
1
I'm not too up-to-date on my matlab, but I believe you can do it by firstly setting hold on
then looping through and plotting each row of your matrix using plot3, and setting the colour based on the label. eg
hold on
for i=1:675,
if (label == 1)
plot3(mat(i,1), mat(i,2), mat(i,3), '-xr');
elseif (label == 2)
plot3(mat(i,1), mat(i,2), mat(i,3), '-og');
elseif (label == 3)
plot3(mat(i,1), mat(i,2), mat(i,3), '-b');
end
end
hold off
This may need some tweaking though, since it is a while since I have used Matlab. Hope it helps :-)
于 2012-05-11T00:34:42.420 に答える