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

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

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With