How to add legend in a 3D scatter plot?

19 次查看(过去 30 天)
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