带有 plot3 和 scatter3 模糊的 matlab 图?

标签 matlab plot matlab-figure

所以第一个情节:

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

yet no problem

还没有问题。当我使用旋转工具旋转图形时,带有 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');

problem occuring

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

我找到了某种应该有效的解决方案: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 才能使其正常工作。

enter image description here

关于带有 plot3 和 scatter3 模糊的 matlab 图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39308821/

相关文章:

c++ - 如何使用 Qt QwtPlot3D 可视化数据

matlab - 为什么 MATLAB 不能绘制单词 "factory"?

python - 将稀疏 scipy 矩阵的行设置为零的最有效方法是什么?

MATLAB 按键对Containers.Map(key, value) 进行排序

matlab - Matlab 中基本矩阵的不同结果

pandas - 如何删除 Dataframe.plot 中的特定图例标签?

r - 在 r 中合并两个图

matlab - 图例 MATLAB For 循环

单图中的 MATLAB 多个(平行)箱线图

MATLAB:在 for 循环中绘制子图