Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot 3D line on top of surface plot in Octave

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):

example

like image 841
Filip S. Avatar asked Nov 17 '25 00:11

Filip S.


1 Answers

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

enter image description here

like image 155
Huguenot Avatar answered Nov 19 '25 14:11

Huguenot