2017-04-24 105 views
2

我有一個MATLAB的顫抖3情節與代碼和情節如下,我希望行接近中心點(這是青色藍色)顏色變化,以便我可以visulize他們距離中心的距離。任何想法我怎麼能這樣做?非常感謝!MATLAB顫動3色彩地圖

hold on; 
grid on; 
scatter3(frame_cur.xyz_cam(1,:),frame_cur.xyz_cam(2,:),frame_cur.xyz_cam(3,:),'MarkerFaceColor',[0 .75 .75]); 
quiver3(frameGT_cur.xyz_cam(1,:),     ... 
     frameGT_cur.xyz_cam(2,:),     ... 
     frameGT_cur.xyz_cam(3,:),     ... 
     C(1,:)-frame_cur.xyz_cam(1,:),  ... 
     C(2,:)-frame_cur.xyz_cam(2,:),  ... 
     C(3,:)-frame_cur.xyz_cam(3,:),  ... 
     0,'b','ShowArrowHead','off');* 

enter image description here

+0

我懷疑這是可能的。 – thewaywewalk

+0

相關:https://stackoverflow.com/questions/29632430/quiver3-arrow-color-corresponding-to-magnitude/36940596 –

回答

4

它不使用quiver3但結果卻是接近你的要求是什麼。這個答案受this answer的啓發。

我用surf的名稱值參數'FaceColor','none','EdgeColor','interp'創建具有插色線:

% generate random 3D points 
n = 10; 
x = 2*rand(n,1)-1; 
y = 2*rand(n,1)-1; 
z = 2*rand(n,1)-1; 
% the color is the distance of each point 
c = sqrt(x.^2 + y.^2 + z.^2); 
% plot the points 
scatter3(x,y,z,40,c,'filled'); 
hold on 
% add zeros (the center point) between points 
xx = [zeros(1,numel(x));x(:)'];xx = xx(:); 
yy = [zeros(1,numel(y));y(:)'];yy = yy(:); 
zz = [zeros(1,numel(z));z(:)'];zz = zz(:); 
cc = [zeros(1,numel(c));c(:)'];cc = cc(:); 
% plot the lines 
h = surf([xx,xx],[yy,yy],[zz,zz],[cc,cc],... 
    'FaceColor','none','EdgeColor','interp','LineWidth',1); 
colorbar; 

enter image description here

+0

感謝它運作良好! – jiayi