Function Repository Resource:

DirectionParametricPlot

Source Notebook

Create a parametric plot of a curve in the plane with direction indicated by arrowheads and color

Contributed by: Dennis M Schneider

ResourceFunction["DirectionParametricPlot"][{fx,fy},{t,tmin,tmax}]

generates a parametric plot of a curve {fx,fy} whose x- and y-coordinates fx and fy are functions of t and with the direction of the curve indicated by color and arrowheads.

Details and Options

The following options are supported:
"ArrowNumber"15number of arrowheads to include in the plot
"ArrowSize"Largesize of the arrowheads
ColorFunctionAutomaticspecify the color function
"DrawArrowheads"Truewhether to include the arrowheads in the plot
PlotStyleAutomaticstyle to be applied to the curve

Examples

Basic Examples (1) 

A curve with direction indicated by color and arrowheads:

In[1]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}]
Out[1]=

Options (11) 

ArrowSize (2) 

The option "ArrowSize"1 corresponds (roughly) to the default "ArrowSize"Large:

In[2]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, "ArrowSize" -> 1]
Out[2]=

The same curve with smaller arrowheads:

In[3]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, "ArrowSize" -> Medium]
Out[3]=

ArrowNumber (2) 

Plot more arrowheads:

In[4]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, "ArrowNumber" -> 25]
Out[4]=

Suppress the arrowheads by setting "ArrowNumber" to zero:

In[5]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, "ArrowNumber" -> 0]
Out[5]=

DrawArrowheads (1) 

Suppress the arrowheads:

In[6]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, "DrawArrowheads" -> False]
Out[6]=

PlotStyle (4) 

Setting PlotStyle to a color plots the curve in that color:

In[7]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, PlotStyle -> Purple]
Out[7]=

Plot two curves with a different style as well as a different size arrowhead for each curve:

In[8]:=
ResourceFunction[
 "DirectionParametricPlot"][{{Cos[t] Cos[2 t], Sin[t]}, {Cos[t] Cos[4 t], Sin[t]}}, {t, 0, 2 \[Pi]}, PlotStyle -> {Thickness[.01], Thickness[.015]}, "ArrowSize" -> {1, 1.3}]
Out[8]=

Other settings for PlotStyle will not affect the automatic coloring:

In[9]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[4 t], Sin[t]}, {t, 0, 2 \[Pi]}, PlotStyle -> Thickness[.01]]
Out[9]=

For multiple curves, if just one style is specified, it is applied to both curves:

In[10]:=
ResourceFunction[
 "DirectionParametricPlot"][{{Cos[t], 2 Sin[t]}, {Cos[t], Sin[t]}}, {t, 0, 2 \[Pi]}, PlotStyle -> Thickness[.017]]
Out[10]=

ColorFunction (1) 

Change the color function:

In[11]:=
ResourceFunction[
 "DirectionParametricPlot"][{Cos[t] Cos[2 t], Sin[t]}, {t, 0, 2 \[Pi]}, ColorFunction -> Function[{x, y, t}, GrayLevel[.8 t]]]
Out[11]=

PlotLegends (1) 

Since PlotLegends depends on the color of the curve, they will not work unless ColorFunction is set to None or the specifications for PlotStyle contain a color:

In[12]:=
ResourceFunction[
 "DirectionParametricPlot"][{{Cos[t], 2 Sin[t]}, {Cos[t], Sin[t]}}, {t, 0, 2 \[Pi]}, ColorFunction -> None, PlotLegends -> "Expressions"]
Out[12]=
In[13]:=
ResourceFunction[
 "DirectionParametricPlot"][{{Cos[t], 2 Sin[t]}, {Cos[t], Sin[t]}}, {t, 0, 2 \[Pi]}, PlotStyle -> {Thickness[.01], {Magenta, Thickness[.013]}}, PlotLegends -> "Expressions"]
Out[13]=

Properties and Relations (2) 

Without DirectionParametricPlot, it is difficult to tell how the curve is traced out:

In[14]:=
ParametricPlot[{Sin[t] Cos[2 t], 2 Sin[t] Cos[t]}, {t, 0, 2 \[Pi]}]
Out[14]=

Using DirectionParametricPlot, it is easy to see how the curve is traced out:

In[15]:=
ResourceFunction[
 "DirectionParametricPlot"][{Sin[t] Cos[2 t], 2 Sin[t] Cos[t]}, {t, 0,
   2 \[Pi]}]
Out[15]=

Publisher

Dennis M Schneider

Version History

  • 1.0.0 – 13 September 2019

Related Resources

License Information