Plot 3D line on top of surface plot in Octave

﹥>﹥吖頭↗ 提交于 2019-12-24 11:53:27

问题


I have plotted a surface from some data. In the same plot I want to have a 3D line (I have the [x,y,z] values for the line I want to plot). When I try to do this using plot3(x,y,z) in the same figure, the line is always below the surface.

Is there any way to fix this? I don't know if this problem appears in Matlab as well.

Minimal example:

figure;
hold all;

y = x = 0:35;
z = ones(1,36).*0.5;
plot3(x,y,z);

[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
surf(Z);

The result (the blue line is below the surface):


回答1:


To answer part of your question, you don't get this problem in MATLAB with the following code:

figure;
hold all;

x = 0:35;
y = x;
z = ones(1,36).*0.5;
plot3(x,y,z);

[X,Y] = meshgrid(-8:.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
surf(Z);




回答2:


I also had this problem with surf in Octave, so I used the mesh function instead. It is not as pretty, and has different parameters but does allow lines to overlay it:

I created that with the same code as above but replacing surf with:

    mesh ((X+8)*2.2, (Y+8)*2.2, Z);

Because mesh needed its parameters to be scaled up. The result is roughly the same.



来源:https://stackoverflow.com/questions/16835454/plot-3d-line-on-top-of-surface-plot-in-octave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!