필터 지우기
필터 지우기

How to make colorbar work for a scatter3 plot?

조회 수: 87 (최근 30일)
Zahra Moussavi
Zahra Moussavi 2016년 8월 23일
댓글: Juan Gonzalez 2022년 11월 25일
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
I would appreciate any help. Thanks

채택된 답변

KSSV
KSSV 2016년 8월 23일
편집: Walter Roberson 2016년 8월 23일
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
Zahra Moussavi
Zahra Moussavi 2016년 8월 23일
It worked. Thank you
Juan Gonzalez
Juan Gonzalez 2022년 11월 25일
It worked magically!
Thank you!

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by