# How to plot a function line with Markers, such as square, triangle, circle and so on?

How to plot a function line with Markers:

f[x_, m_] = m Sin[x]
g[x_, m_] = 2 m Cos[x]
Manipulate[
Plot[{f[x,m], g[x,m]}, {x, 0, 10},
PlotLegends -> Automatic], {m, 0, 5}]


how to add markers like this automatic:

• The question is vague. There seems to be no need for complicating it further with Manipulate. You can photoshop what marker you want and at which points perhaps. Thanks.
– Syed
Jan 17 at 8:02
• @Syed I agree, when I first read this, I did not understand what the question meant. But I think they meant the Manipulate did not work. I could be wrong. Jan 17 at 8:06
• @Nasser, the OP has clarified it somewhat in the meantime, but I think that it is still not clear enough for a definitive answer.
– Syed
Jan 17 at 8:08
• @Syed if you run the code they show as is (from clean kernel) you will notice the Manipulate does not work. So I have no idea how they obtained that screen shot. I am on V 13.2. Jan 17 at 8:09
• @Nasser I was under the impression that the author of the OP wanted to fix manipulate and change PlotMarkers at the same time. Anyway, I like your answer :-)
– bmf
Jan 17 at 8:10

f[x_, m_] := m Sin[x]
g[x_, m_] := 2 m Cos[x]
r0 = Table[{x, f[x, m]}, {x, 0, 10}];
r1 = Table[{x, g[x, m]}, {x, 0, 10}];
Manipulate[
ListPlot[{r0, r1} /. m -> mm,
PlotMarkers -> {"\[FilledSquare]", "\[FilledCircle]"},
Joined -> True, PlotRange -> {Automatic, {-5, 5}},
InterpolationOrder -> 10], {mm, 1, 5}]


Edit: thanks to @Syed

If I understand correctly something like the following:

f[x_, m_] := m Sin[x]
g[x_, m_] := 2 m Cos[x]

Manipulate[
DiscretePlot[Evaluate[{f[x, m], g[x, m]}], {x, 0, 10},
PlotRange -> {-10, 10}, Filling -> None,
PlotMarkers -> {{"\[FilledSquare]", 10}, {"\[FilledCircle]", 10}},
PlotLegends -> "Expressions"], {m, 0, 5}]


Edit 2: connecting the points

Manipulate[
DiscretePlot[Evaluate[{f[x, m], g[x, m]}], {x, 0, 10},
PlotRange -> {-10, 10}, Filling -> None,
PlotMarkers -> {{"\[FilledSquare]", 10}, {"\[FilledCircle]", 10}},
PlotLegends -> "Expressions", Joined -> True], {m, 0, 5}]

• Add: , PlotRange -> {-10, 10} for visual benefit.
– Syed
Jan 17 at 8:11
• @Syed you are absolutely right. Many thanks!
– bmf
Jan 17 at 8:12
• This plot Discrete Points, but without lines about function, I want keep lines. Jan 17 at 8:13
• @ChinChingCHAN see the edit please
– bmf
Jan 17 at 8:16
• @bmf The line seems not smoothly. Jan 17 at 8:19

I am not sure if this is what you meant or not. (I assumed you meant your Manipulate was not working). Will delete if not.

f[x_, m_] := m Sin[x]
g[x_, m_] := 2 m Cos[x]
Manipulate[
Plot[{f[x, m], g[x, m]}, {x, 0, 10}, PlotLegends -> Automatic,
PlotRange -> {Automatic, {-5, 5}}],
{m, 0, 5},
TrackedSymbols :> {m}]


The reason Manipulate did not work, is because m did not show in the expression. The control variable must show in the expression for it to work.