How to add legend in a 3D scatter plot?

조회 수: 22 (최근 30일)
Hassan Ashraf
Hassan Ashraf 2020년 7월 5일
편집: madhan ravi 2020년 7월 5일
I have following piece of code. I am using tsne visualization to plot 3D scatter plot. But I am unable to find a way to add legends.
clear all; clc; close all;
load('trLabels.mat')
load('trFeatures.mat')
X = trSets;
L = labels;
rng default % for fair comparison
Y3 = tsne(X,'Algorithm','barneshut','NumPCAComponents',20,'NumDimensions',3);
figure
scatter3(Y3(:,1),Y3(:,2),Y3(:,3),15,L,'filled', '');
colormap( jet(numel(unique(L))) )

답변 (1개)

madhan ravi
madhan ravi 2020년 7월 5일
  댓글 수: 5
madhan ravi
madhan ravi 2020년 7월 5일
편집: madhan ravi 2020년 7월 5일
Can’t help without looking at your file, I would see 11 calls to scatter3() or a loop whereas you have only one ? and you expect 11 entries?
Hassan Ashraf
Hassan Ashraf 2020년 7월 5일
I have added the data files and below is my code.
clear all; clc; close all;
load('trLabels.mat')
load('trFeatures.mat')
X = trSets;
L = labels;
rng default % for fair comparison
Y3 = tsne(X,'Algorithm','barneshut','NumPCAComponents',20,'NumDimensions',3);
figure
scatter3(Y3(:,1),Y3(:,2),Y3(:,3),20,L,'filled', '');
colormap( jet(numel(unique(L))) )
legend(compose('Entry %d', 1:11))

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

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by