# Arrowhead as MeshStyle or PlotMarkers for ListLinePlot

Is it possible to use the Meshstyle option of the PlotMarkers option in ListLinePlot to have Arrowheads as a point marker, obviously pointing in the positive direction of the line at that point? Using the example below, what sort of function would I need in the MeshStyle option.

ListLinePlot[Range[10]^2]


If not, what alternative solution might exist?

A quite simple solution is to replace the Line directives with Arrow. Sine there is usually only one Line directive, you have to partition the list of points manually:

ListLinePlot[Range[10]^2] /.  Line[pts_] :> (Arrow /@ Partition[pts, 2, 1])


• Aha! Now to go and learn about RuleDelayed. Many thanks. Dec 6, 2013 at 3:55

what sort of function would I need in the MeshStyle option

You can place arrows on the line using Mesh, MeshFunctions and MeshShading options:

ListLinePlot[Sin@Range[0, 4 Pi, 4 Pi/50],
MeshFunctions -> {#2 &}, Mesh -> 6, MeshStyle -> Opacity[0],
MeshShading -> {Arrowheads[Medium]}, DataRange -> {0, 4 Pi}] /. Line -> Arrow


Using

MeshShading -> {Directive[Arrowheads[Small], Dotted, Red],


we get

Using different setting for MeshFunctions:

ListLinePlot[Range[-10, 10]^2, MeshFunctions -> {"ArcLength"},
Mesh -> 20, MeshStyle -> Opacity[0],
AspectRatio -> 1] /. Line -> Arrow


For function plotting:

f[x_] := x^2; (* define a function to plot *)
df = 1/4; (* define a step size for the arrows *)

g[x_] := Sin[x];
dg = Pi/16;

{
Plot[f[x], {x, -5, 5}, Epilog -> Table[{Red, AbsolutePointSize[3],
Arrow[{{i - df, f[i - df]}, {i + df, f[i + df]}}]
}, {i, -5, 5, 2 df}], ImageSize -> 300],
Plot[g[x], {x, 0, 6 Pi}, Epilog -> Table[{Red, AbsolutePointSize[3],
Arrow[{{i - dg, g[i - dg]}, {i + dg, g[i + dg]}}]
}, {i, 0, 6 Pi, 2 dg}], ImageSize -> 300]
}


ListLinePlot[Range[10]^2]/.Line[x__]:>{Arrowheads[Table[.05,10]],Arrow[x]}