6
$\begingroup$

I have a 3D function (z = f(x, y)). I have plot it correctly as you can see below. Now, I want to show that there are two different paths to reach from Point A to Point B as shown in the following image.

enter image description here

As you can see, I have done it using Shockwell in Linux. But, I want to do it in a clean manner in Mathematica. How can I plot a path from Point A to B while the path is on the surface?

And, if it is possible, as you can see, my preference is to draw an arrow. But, it is not totally necessary.

$\endgroup$
11
$\begingroup$

Draw your plot with Plot3D and your paths with ParametricPlot3D, then combine them with Show

zfunc[x_, y_] := Exp[x y];
path1[x_] := x^2
path2[x_] := Sqrt[x]

Show[
 Plot3D[zfunc[x, y], {x, 0, 1.1}, {y, 0, 1.1}],
 (ParametricPlot3D[{
     {x, path1[x], zfunc[x, path1[x]]},
     {x, path2[x], zfunc[x, path2[x]]}},
    {x, 0, 1},
    PlotStyle -> {Directive[{Red, Arrowheads[.02]}], 
      Directive[{Blue, Arrowheads[.02]}]}] /. Line -> Arrow)
 ]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks Jason. Sorry for late response. I was wondering for two things. 1- sometimes the arrow hides behind the surface. How can I bring it forward? 2- Since I am a little bit stupid on Mathematica, how can I increase arrow's width? Make it bolder as we speak. $\endgroup$ – Millad Sep 21 '16 at 18:34
  • 1
    $\begingroup$ To make the path always on top of the surface, you could manually put in an offset in the z-coordinate of the paths: ParametricPlot3D[{{x, path1[x], zfunc[x, path1[x]] + .01}, {x, path2[x], zfunc[x, path2[x]] + .01}} for example offsets the plot by 0.01 in the z-direction. $\endgroup$ – Jason B. Sep 21 '16 at 19:50
  • 1
    $\begingroup$ To bolden the lines, you could change Line-> Arrow to Line[pts_] :> Arrow[Tube[pts, .0075], {0, -.1}] $\endgroup$ – Jason B. Sep 21 '16 at 19:53
  • $\begingroup$ Thanks Jason. Appreciate it. I was hoping that there might be a way to show the arrows like threads. This way that you are mentioning would shift the arrow up which in some cases will detach the arrow from the surface. Also, for the top gray section, it will have no effect :) $\endgroup$ – Millad Sep 21 '16 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.