How to make colorbar work for a scatter3 plot?
74 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zahra Moussavi
am 23 Aug. 2016
Kommentiert: Juan Gonzalez
am 25 Nov. 2022
Hi,
I am plotting a set of scatter points using the below code. It works perfectly and the graph is correct. But the colorbar is just showing values between 0 and 1 and I don't know how I can reflect the actual values of the graph.
[NUM,LETTER]= xlsread('B.xlsx','S1');
M=NUM(:,1:3);
z=M(:,2)
y=M(:,1)
x=M(:,3)
[carbon,idx]=sort(z)
yyy=y(idx)
xxx=x(idx)
zzz=z(idx)
cmp=jet(numel(z))
scatter3(xxx, yyy, zzz, 15, cmp);
colorbar
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155936/image.jpeg)
I would appreciate any help. Thanks
0 Kommentare
Akzeptierte Antwort
KSSV
am 23 Aug. 2016
Bearbeitet: Walter Roberson
am 23 Aug. 2016
Eg: To use scatter and color plot
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
c = linspace(1,10,length(x));
scatter(x,y,[],c)
colorbar
In your case try
scatter3(xx,yy,zz,[],zz) ;
colorbar
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!