gpt4 book ai didi

带有 plot3 和 scatter3 模糊的 matlab 图?

转载 作者:太空宇宙 更新时间:2023-11-03 20:33:21 25 4
gpt4 key购买 nike

所以第一个情节:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com