# ParametricPlot with plot markers

I have a parametric plot, and would like to fit a line to it with "■" PlotMarkers on it, but am unable to do so.

ParametricPlot[{f(x), g(x)}, {x, 0, 1}, AxesLabel -> {"x", "y"}, PlotMarkers->{"■", 10.9}]

• @Öskå yeah that's why I'm asking Jun 11 '14 at 15:06
• @Öskå i'd like to use PlotMarkers->{"■"} on it. Jun 11 '14 at 15:11
• @Öskå this one but I'd like to use PlotMarkers->{"■"} Epilog -> {Red, PointSize[Large],Point[{f(x), g(x)}, AspectRatio -> 1, PlotStyle -> Thick, PlotRange -> All, ImageSize -> Medium] Jun 11 '14 at 15:20
• Herman, the point is that PlotMarkers is not an Option for ParametricPlot: MemberQ[Options[ParametricPlot], PlotMarkers -> _] is False. You cannot use it unless you use a modified definition for ParametricPlot. Presumably you are asking for behavior akin to PlotMarkers; is that correct? Jun 11 '14 at 15:24
• Related question Jun 11 '14 at 16:18

You can add plot markers by manipulating the Graphics output of ParametricPlot.

marker = Style["\[FilledDiamond]", FontSize -> 10.88];

ParametricPlot[{Sin[u], Sin[2 u]}, {u, 0, 2 Pi}, Mesh -> 50] /.
Point[x : {__Integer}] :> Map[Inset[marker, #] &, x] To put markers of different styles on multiple lines is more complicated but I will try to solve that later.

I couldn't think of any clever way to do multiple markers at once so here's the blunt way:

plot[fn_, mk_, sty_] :=
ParametricPlot[fn, {t, 0, 2 Pi}, PlotStyle -> sty, Mesh -> 30] /.
Point[x : {__Integer}] :> {sty, Map[Inset[mk, #] &, x]}

{
{{2 Cos[t], Sin[t]}, {Cos[t], 2 Sin[t]}, {Cos[t], Sin[t]}},
Style[#, FontSize -> 10.88] & /@ {"\[FilledDiamond]", "\[FilledSquare]", "\[Wolf]"},
{Red, Green, Blue}
}
] // Show[#, PlotRange -> All] & Note: I did not bother to localize t because I don't expect you to use this code as-is. Wrap everything in Block[{t}, . . . ] if you wish. Hopefully someone else has a cleaner approach to the whole problem.

• Wizard - Looking at your first example, the figure eight, I would like to observe that the markers are unpleasantly arranged by Mathematica. (Look at the 4 points around [0,0]). This missing symmetry would become even worse in my answer. Tried to find a solution to this during the last hour, but to no avail.
– eldo
Jun 11 '14 at 20:42
• @eldo For even spacing read this: (8454) Jun 11 '14 at 20:57
• Thanks for this must-read. I'll try it tomorrow with the "eight".
– eldo
Jun 11 '14 at 21:26
f[x_] = x Cos[x];
g[x_] = x Sin[x];

ParametricPlot[{f[x], g[x]}, {x, 0, 4 Pi}, AxesLabel -> {"x", "y"}, Mesh -> {{#,
Text[Style["\[FilledSquare]", Red, 10.9], {f[#], g[#]}]} & /@
Range[0, 4 Pi, Pi/8]}] Nice evenly spaced points

 marker = GraphicsPlotMarkers[][[4, 1]]
ListLinePlot[
t = Table[{u Cos[u], u Sin[u]} // N, {u, 0, 4 Pi, 4 Pi/1000}],
AspectRatio -> 1/GoldenRatio,
Epilog -> (Text[Style[marker, Blue, 10.9], #] & /@ (linepoints[t, 30]) )]


with linepoints from here : Is it Possible to change dashes into circles with Plot command? or if you want to use ParametricPlot:

 marker = GraphicsPlotMarkers[][[4, 1]];
t = Table[{u Cos[u], u Sin[u]} // N, {u, 0, 4 Pi, 4 Pi/1000}];
ParametricPlot[{u Cos[u], u Sin[u]} // N, {u, 0, 4 Pi},
Epilog -> (Text[Style[marker, Blue, 10.9], #] & /@ (linepoints[t,30]) )]


Edit: modified the interpolation to return the arc length parameter to work with Mesh :

 linepointsP[plist_, n_] := Module[{},
arc = Interpolation[(Transpose@{{0}~Join~
Accumulate@(Norm@(Subtract @@ #) & /@ Partition[plist, 2, 1]),
N@Range[0, Length[plist] - 1]/(Length[plist] - 1)}),
InterpolationOrder -> 3];
tlen = Last@First@First@(arc);
Table[arc[tlen iz/n], {iz, 0, n}]];
marker = GraphicsPlotMarkers[][[4, 1]];
{umin, umax} = {.1, 10 Pi};
g[u_] :=  (u/umax)^(5) {  Cos[u], Sin[u]};
nmarkers=100;
ndis = 1000; (* # points adequate to create a good cubit interpolation function *)
ParametricPlot[g[u], {u, umin, umax} ,
Mesh -> {(umin + (umax - umin ) #) & /@
linepointsP[Table[g[u], {u, umin, umax, (umax - umin)/ndis}],
nmarkers]  },
MeshStyle -> (Map[
Inset[Style[marker, Green, 12], #] &, #] & @@ ## &),
PlotRange -> All] • Except the marker style you would get the same result using the shorter code below :)
– eldo
Jun 17 '14 at 15:39
• @eldo This approach does not require analytically differentiating the function. I guess I should have said that, but it is in the link. Jun 17 '14 at 16:00
• understood, thank you
– eldo
Jun 17 '14 at 16:18

Update: For multiple functions, we can use the MeshStyle trick on each one separately and combine the results using Show:

funcs = {{2 Cos[t], 2 Sin[t]}, {2 Cos[t], Sin[t]},
{Sin[t] Cos[t], 2 Sin[t]}, {Cos[t], Cos[t] Sin[t]}};
mesh = {50, 30, 40, 20};
colors = ColorData[1, "ColorList"][[;; 4]];
markers = {"◆", "■",  "▲", "◇"};

Show[Module[{ins = Style[#4, #3, 16]},
ParametricPlot[#, {t, 0, 2 Pi}, Mesh -> #2, PlotStyle -> #3,
MeshStyle -> (Function[w, Map[Function[z, Inset[ins, z]], w]] @@ ## &)]] & @@@
Transpose[{funcs, mesh, colors, markers}]] You can also use MeshStyle as follows:

ParametricPlot[{Sin[u], Sin[2 u]}, {u, 0, 2 Pi}, Mesh -> 50,
MeshStyle -> (Map[Inset[Style["\[FilledDiamond]", Blue, 16], #] &, #] & @@ ## &)] • Very nice! That's far more direct. +1 Jun 12 '14 at 4:05

I've been thinking all day about the wonderful solutions (by @Mr.Wizard, @eldo, @Bob Hanlon and @kguler) and would like to show my approach. One can find the PlotMarkers with the command

markers = GraphicsPlotMarkers[] And also assign them, i.e. stripping List of Lists;

m1 = markers[[All, 1]] The following was pretty easy

p1 = ListPlot[Table[{Sin[n], Sin[4 n]}, {n, 6 \[Pi]}],
PlotStyle -> {Red}, PlotMarkers -> {m1[]}];
p2 = ParametricPlot[{Sin[u], Sin[4 u]}, {u, 0, 2 Pi}]

Show[p2, p1] • +1 - I particularly like this markers = GraphicsPlotMarkers[]. Never saw it before.
– eldo
Jun 13 '14 at 20:46

Thanks to Szabolcs solution in link I can now plot symmetric points:

eight := {Cos[t], Sin[2 t]}
lim = 2 Pi;

Off[FunctionInterpolation::ncvb]

velocity = FunctionInterpolation[Evaluate@Norm@D[eight, t], {t, 0, lim}];
arclength = Derivative[-1][velocity];
inverse = InverseFunction[arclength];

points = eight /. t -> # & /@
Table[inverse[x], {x, 0, arclength[lim], arclength[lim]/20}];

Show[ParametricPlot[eight, {t, 0, lim}, PlotStyle -> Black],
ListPlot[points, PlotStyle -> Directive[PointSize[0.02], Red]]]
` 