3
$\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$
  • 1
    $\begingroup$ Your list of differential equations is bad-constructed, second item is not an equation. $\endgroup$ – rhermans Nov 11 '15 at 8:10
  • $\begingroup$ @rhermans, how would you recommend to construct it? $\endgroup$ – jarhead Nov 11 '15 at 8:12
  • 1
    $\begingroup$ Add an == followed by a value. $\endgroup$ – Sjoerd C. de Vries Nov 11 '15 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$ – Sjoerd C. de Vries Nov 11 '15 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$ – Sjoerd C. de Vries Nov 11 '15 at 8:44
11
$\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!

| improve this answer | |
$\endgroup$

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