【问题标题】:MATLAB quiver3 colormapMATLAB quiver3 颜色图
【发布时间】:2017-09-21 07:28:31
【问题描述】:

我在 MATLAB 上有一个 quiver3 绘图,其代码和绘图如下,我希望这些线在接近中心点(青蓝色)时具有颜色变化,以便我可以可视化它们的距离中心。知道我该怎么做吗?非常感谢!

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');*

【问题讨论】:

标签: matlab scatter colormap


【解决方案1】:

它没有使用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;

【讨论】:

    猜你喜欢
    • 2015-06-20
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 2018-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多