3D分散绘图Matlab与连接点

时间:2013-01-29 15:05:00

标签: matlab plot

我想在Matlab中连接具有相同Z值的三维散点图中的点。

num=1e2;
x=rand(num,1);
y=rand(num,1);
z=zeros(num,1);
z(randsample(num,.25*num),:)=1;
scatter3(x,y,z);hold on;scatter3(x1,y1,z1);hold on;
%connect dots with same Z value, so there should be horizontal line between points in the same Z plane

1 个答案:

答案 0 :(得分:0)

当你说“连接点”时,我不确定你的想法,但这是一个方向:

figure, hold on
for u = unique(z(:))'
    plot3(x(z == u), y(z == u), z(z == u))
end
view(-37.5, 30)

或者,您可以修改数据并改为使用contour3命令。