5
$\begingroup$

I'm trying to add arrow to a simple parametric plot I'm doing:

F=1.85;
c=1.85;
G=0.01;
sol = NDSolve[{x'[t]==v[t], v'[t]==-v[t]+c Tanh[v[t]/F]-G Sign[x[t]],x[0]==0,v[0]==0.01},{x,v},{t,0,10}];
ParametricPlot[Evaluate[{x[t], v[t]} /. sol], {t, 0, 10}]

I've added the arrows. There is some similar question here in the forum, Adding arrows in curves however it is not with parametric plot, and works with ListPlot, I'm new in mathematica and don't find my way with this yet, any help or guidance would be much appreciated.

enter image description here

$\endgroup$
9
  • 1
    $\begingroup$ Your list of differential equations is bad-constructed, second item is not an equation. $\endgroup$
    – rhermans
    Nov 11, 2015 at 8:10
  • $\begingroup$ @rhermans, how would you recommend to construct it? $\endgroup$
    – jarhead
    Nov 11, 2015 at 8:12
  • 1
    $\begingroup$ Add an == followed by a value. $\endgroup$ Nov 11, 2015 at 8:18
  • 2
    $\begingroup$ All I (and rhermans too) was saying is that the second term in the NDSolve, v'[t]+c Tanh[v[t]/F]-G Sign[x[t]] is not an equation because it doesn't have a ==. $\endgroup$ Nov 11, 2015 at 8:32
  • 2
    $\begingroup$ Just add /. Line[x_] :> {Arrowheads[Table[.05, {5}]], Arrow[x]} after the ParametricPlot (as in the accepted answer in the question you linked to). I've checked it, and it works here too. $\endgroup$ Nov 11, 2015 at 8:44

1 Answer 1

16
$\begingroup$

Try this:

    F = 1.85;
c = 1.85;
G = 0.01;
sol = NDSolve[{x'[t] == v[t], 
    v'[t] == -v[t] + c Tanh[v[t]/F] - G Sign[x[t]], x[0] == 0, 
    v[0] == 0.01}, {x, v}, {t, 0, 10}];

ParametricPlot[Evaluate[{x[t], v[t]} /. sol], {t, 0, 10}] /. 
 Line[x_] :> {Arrowheads[{0., 0.07, 0.07, 0.07, 0.}], Arrow[x]}

and play with the list under the Arrowheads to adjust the number and position of the arrows:

enter image description here

or alternatively you may use the following strategy:

    Show[{
  ParametricPlot[Evaluate[{x[t], v[t]} /. sol], {t, 0, 1}, 
    PlotRange -> {-0.01, 0.01}] /. 
   Line[x_] :> {Arrowheads[{0.07}], Arrow[x]},
  ParametricPlot[Evaluate[{x[t], v[t]} /. sol], {t, 1, 2}],
  ParametricPlot[Evaluate[{x[t], v[t]} /. sol], {t, 2, 3}] /. 
   Line[x_] :> {Arrowheads[{0.07}], Arrow[x]},
  ParametricPlot[Evaluate[{x[t], v[t]} /. sol], {t, 3, 4}]
  }]

giving this:

enter image description here

Have fun!

$\endgroup$
0

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