繁体   English   中英

matlab情节与plot3和scatter3阻塞?

[英]matlab plot with plot3 and scatter3 obscurring?

首先是情节:

clear all; close all;
figure; hold on
points=[0 0 0; 0.5 0 0; 0.5 0.5 0; 0 0.5 0; 0 0 0];
plot3(points(:,1), points(:,2), points(:,3),'c','linewidth', 2);
scatter3(points(:,1),points(:,2),points(:,3),40,'filled','k');

但没问题

但没问题。 当我使用旋转工具旋转图形时,带有scatter3的点图总是显示在线图的顶部。

现在!!

当我绘制:

figure;
hold on;
points=[0 0 0; 0.5 0 0; 0.5 0.5 0; 0 0.5 0; 0 0 0; ...
        0 0 1; 0.5 0 1; 0.5 0.5 1; 0 0.5 1; 0 0 1];
plot3(points(:,1), points(:,2), points(:,3),'c','linewidth', 2);
sc=scatter3(points(:,1),points(:,2),points(:,3),40,'filled','k');

出现问题

当我旋转图形时,线条图几乎总是位于散点的顶部(取决于角度的一点点),这不是我想要的。

我找到了一些应该有效的解决方案: uistack(sc)

它不起作用。

那么我该怎样做才能使分散点像第一个数字一样显示? 非常感谢答案。 这对我的硕士论文来说非常重要:D

我尝试了不同的方法。
我没有使用scatter3 ,而是使用了球体。
效率较低,但仍然不完美......但我找不到更好的解决方案。

这是我的代码示例:

figure;
set(gca, 'xlim', [-0.005, 0.505], 'ylim', [-0.005, 0.505], 'zlim', [-0.005, 1.005]);

hold on;
points=[0 0 0; 0.5 0 0; 0.5 0.5 0; 0 0.5 0; 0 0 0; ...
        0 0 1; 0.5 0 1; 0.5 0.5 1; 0 0.5 1; 0 0 1];
plot3(points(:,1), points(:,2), points(:,3),'c','linewidth', 2);
sc=scatter3(points(:,1),points(:,2),points(:,3),40,'filled','k');


[x,y,z] = sphere(20);   %Returns the coordinates of the 20 by 20 sphere

for i = 1:length(points)
    x0 = points(i, 1);
    y0 = points(i, 2);
    z0 = points(i, 3);
    h_surf = surf(gca, x*0.004+x0, y*0.004+y0, z*0.004+z0, 'FaceColor', 'black', 'LineWidth', 2);
end

注意:我必须设置xlimylimzlim才能使它工作。

在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM