MATLAB Answers

0

Getting colors using RGB values w/ scatter3

Hans123 님이 질문을 제출함. 16 Jul 2019
최근 활동 Adam Danz 님이 댓글을 추가함. 16 Jul 2019
I am trying to get grey colored plot points on my 3D scatter plot, I am unfamiliar with scatter3. From the error messages I am getting using the conventional method (on a regular plot, shown below) - I am assuming there should be an established color vector.
This is what I have currently
scatter3(X,Y,Z,'filled', c, [17 17 17]);

  댓글 수: 0

로그인 to comment.

태그

답변 수: 1

Adam Danz 님의 답변 16 Jul 2019
Adam Danz 님이 편집함. 16 Jul 2019
 채택된 답변

rgb triplets are normalized between 0:1
To convert from decimal code, divide by 255.
[17,17,17]./255
% equals
[ 0.066667 0.066667 0.066667]
The color gray is
% RGP TRIPLE %CSS3 proposed standard name: https://www.w3.org/TR/css-color-3/
[0.5 0.5 0.5] %gray
[0.82422 0.82422 0.82422] %light gray
[0.75 0.75 0.75] %silver
[ 0.66016 0.66016 0.66016] %dark gray
[0.14844 0.14844 0.14844] %mine shaft
[ 0.4375 0.5 0.5625] %slate gray
See the rgb() function on the file exchange for RGB triplets to many different colors.
To apply that to scatter3; here's how to color all points gray and filled.
scatter3(x,y,z,[],[.5,.5,.5],'filled')

  댓글 수: 4

표시 이전 댓글 수: 1
See this example
scatter3(x,y,z,[],c)
c is the matrix of rgb triplets. If you want all points to be the same color and filled,
scatter3(x,y,z,[],[.5,.5,.5],'filled')
works perfectly.
thanks for the link too, really appreciate it
Glad I could help!

로그인 to comment.



Translated by