7
$\begingroup$

I have a bunch curve that I would like to add arrowheads to. A working example is this one,

ParametricPlot[
 {-Re[Cos[0.0456 (2.9 + 18.2 I - I s)]], 
  -Im[Cos[0.0456 (2.9 + 18.2 I - I s)]] + 0.008 s}
 , {s, 0, 18.2}
 , ImageSize -> 600
 , Frame -> True
 ]

which roughly looks like this:

Mathematica graphics

Unfortunately, when I do the standard thing and substitute my Line element for an Arrow,

ParametricPlot[
 {-Re[Cos[0.0456 (2.9 + 18.2 I - I s)]], 
  -Im[Cos[0.0456 (2.9 + 18.2 I - I s)]] + 0.008 s}
 , {s, 0, 18.2}
 , ImageSize -> 600
 , Frame -> True
 ]/. {Line[stuff_] -> Arrow[stuff]}

I get some pretty funky output, with the arrowhead detached from the rest of the curve:

Mathematica graphics

The effect can be seen a bit better by setting AspectRatio → 1, which looks like this:

Mathematica graphics

This is a bit of a problematic curve to arrowify, since it has a very sharp uptick at the end, but that should be something for me to handle, not something that should cause Mathematica to go belly up and stop displaying the curve.

How can I add an arrowhead to this curve?

$\endgroup$

1 Answer 1

5
$\begingroup$

Arrow can't handle so many points? Drop them.

ParametricPlot[{-Re[
     Cos[0.0456 (2.9 + 18.2 I - I s)]], -Im[
      Cos[0.0456 (2.9 + 18.2 I - I s)]] + 0.008 s}, {s, 0, 18.2}, 
  ImageSize -> 600, Frame -> True, 
  AspectRatio -> 
   1] /. {l : Line[stuff_] :> {l, Arrow@stuff[[{-2, -1}]]}}

enter image description here

$\endgroup$
2
  • $\begingroup$ Yeah, that's brilliant. It does weirdly add a dot at the end, so it still needs some fiddling, but it does the job. $\endgroup$ Commented Sep 1, 2016 at 13:21
  • 2
    $\begingroup$ You can wrap the Arrow in a list and supply Arrowheads up front if you want to control the size and/or color of the arrowhead. {l, {Red, Arrowheads[0.02], Arrow@stuff[[{-2, -1}]]}} $\endgroup$ Commented Sep 1, 2016 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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