Im trying to plot n [X,Y,Z] dots in 3d with their colors given by C which is a nx3 matrix describing the RGB colors for each dot (graded colors).... but its not working!!!!
scatter3(X,Y,Z,S,C, 'filled')
any suggestions?

 채택된 답변

Geert
Geert 2013년 9월 5일

0 개 추천

Have a look at the example in the help:
[x,y,z] = sphere(16);
X = [x(:)*.5 x(:)*.75 x(:)];
Y = [y(:)*.5 y(:)*.75 y(:)];
Z = [z(:)*.5 z(:)*.75 z(:)];
S = repmat([1 .75 .5]*10,numel(x),1);
C = repmat([1 2 3],numel(x),1);
scatter3(X(:),Y(:),Z(:),S(:),C(:),'filled')

댓글 수: 4

Mario Trevino
Mario Trevino 2013년 9월 5일
in my case X is [n x 1] and C is [n x 3], that's where Im stuck
You have to set up each row of C to give the color you want for that data marker. For example, if you want marker #42 to have magenta, you need to do this:
C(42, :) = [1 0 1]; % Row 5 for marker #5 is magenta.
Same for all the other markers. So . . . what did you actually do?
Mario Trevino
Mario Trevino 2013년 9월 5일
ok great... found the problem. I defined each column of C within the range 0-255, and this is what was making the plotter fail. Once I normalized my colors dividing by 255 it all worked nice. thanks!!!!!!!
Yes, any function in MATLAB that takes a 3 element numerical array for color must be in the range 0-1 instead of 0-255. If you have 255 numbers, for example determined them from some artwork in Photoshop of wherever, then you can just divide by 255
color255 = [100, 150, 240];
myColor = color255 / 255; % Then use this array in scatter() or wherever...

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

질문:

2013년 9월 5일

댓글:

2014년 7월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by