Message Boards Message Boards


Arrow at the end of a parametric plot

Posted 9 years ago
6 Replies
2 Total Likes

I would like to add an arrowhead to the end of the parametric plot:

ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 1}]

Is there an option to ParametricPlot to do this? I could not find it. If there is no option, can you please suggest a way to do this?

POSTED BY: Ferenc Beleznay
6 Replies

I found a much better and simpler solution on stackexchange that works with diffrent plots including "ParametricPlot". thanks to the user kglr

p0 = ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 1}]

(*numbers used Arrowheads argument define the size of arrow heads and plot will be divided bt the length of arguments in list to place arrow*)
(*negative numbers means reverse arrow*)
p0 /. Line[x_] :> {Arrowheads[{.1}], Arrow[x]}

enter image description here

p0 /. Line[x_] :> {Arrowheads[{-.1, .1}], Arrow[x]}

enter image description here

p0 /. Line[x_] :> {Arrowheads[{-.1, .5}], Arrow[x]}

enter image description here

p0 /. Line[x_] :> {Arrowheads[{-.1, .1, .1, .1}], Arrow[x]}

enter image description here

Unfortunately, version dependent solution is not good enough for me.


I was hoping for a more elegant solution.

And your hope comes true ... you program it along the following lines

In[34]:= Clear[arrowParametricPlot]
arrowParametricPlot[f_List, p_List] := Block[{[Delta] = (p[[3]] - p[[2]])/100.},
   ParametricPlot[f, p, Epilog -> {Arrowheads[.1, 0], Arrow[{f /. p[[1]] -> p[[3]] - [Delta], f /. p[[1]] -> p[[3]]}]}, PlotRange -> All]
   ] /; Length[f] == 2 &&  Length[p] == 3 && !FreeQ [f[[1]], p[[1]]] && !FreeQ[f[[2]], p[[1]]]

producing pictures like

enter image description here

of course, there's no free lunch, so get the color of the arrow right on your own, please.

POSTED BY: Udo Krause

Check with

In[7]:= FullForm[ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 1}]]

where the function data are and draw an arrow there

In[13]:= Graphics[Arrow[ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 1}][[1, 1, 3, 2]]], Axes -> True]


POSTED BY: Udo Krause

Thank you, this worked to some extent, but not in all the cases I need it. For example in

Graphics[Arrow[ParametricPlot[{Cos[t], Sin[t]}, {t, 0, -1}][[1, 1, 3, 2]]], Axes -> True]

the arrow goes to the wrong end of the curve. It goes to the end corresponding to t=0, not to t=-1. Is there some place I can look up a documentation how the FullForm of ParametricPlot is generated?

POSTED BY: Ferenc Beleznay

Then one uses Arrowheads[]

In[180]:= Graphics[{Arrowheads[{-.1, 0}], Arrow[ParametricPlot[{Cos[t], Sin[t]}, {t, 0, -1}][[1, 1, 3, 2]]]}, Axes -> True]

or even better does a function headEnd[] to generate {-.1, 0} or {0,.1} to place the heads to the right end with the right orientation.

There is a documentation for FullForm, one looks into it's output and finds out, where the interesting things do appear, just try it yourself. This method is unfortunately not version independent, but given that Mathematica is also modular (everything is an expression), it is often successful.

POSTED BY: Udo Krause

Unfortunately, version dependent solution is not good enough for me. I am trying to come up with some demonstrations to illustrate high school mathematics concepts (in this case the argument of a complex number), and it would not be acceptable to write a demonstration that works differently (or not work at all) a year from now. I will then simply put an arrowhead to the appropriate place by calculating the position. I was hoping for a more elegant solution. To be honest I don't really see a reason behind this implementation of ParametricPlot. Why is the FullForm output the same if the limits of the parameter interval change? Surely the starting and end values of the parameter interval have some meaning, even though the output is the same if we change them. In any case thank you for your help.

POSTED BY: Ferenc Beleznay
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract