Update 2: Dealing with question in the comments:
My original code is much longer and with multiple functions. I don't use the command Show
in it. So if i add /. Line->Arrow
all functions get an arrow. Is there a possibility to use /. Line ->Arrow
separately on functions?
You can put the /. Line->Arrow
piece after Plot[...]
, and specify Arrowheads[0]
for the lines that you want to be rendered as Line
s as part of the PlotStyle
setting. For example:
Manipulate[Plot[{a*Sin[x], func[x, b],
ConditionalExpression[0, func[x, b] <= a Sin[x]],
ConditionalExpression[0, func[x, b] >= a Sin[x]]}, {x, 0, 2 Pi},
PlotStyle -> {Directive[Thick, Arrowheads[0], ColorData[54, "ColorList"][[1]]],
Directive[Thick, Arrowheads[0], ColorData[54, "ColorList"][[2]]],
Directive[Red, Thick, Arrowheads[{0, .05}]],
Directive[Blue, Thick, Arrowheads[{-.05, 0}]]}] /. Line -> Arrow,
{a, 1, 10}, {b, 0.5, 10}]

Note: In version 9, you don't have to use /. Line->Arrow
trick. You can use functions to specify the PlotStyle
and use ({Directive[Blue, Thick, Arrowheads[{-.05, 0}], Arrow@@#}&) in place of
Directive[Blue, Thick, Arrowheads[{-.05, 0}]`. But this method no longer works in newer versions.
Update: If you have Version 10 or newer versions, you can also use NumberLinePlot
as Epilog
:
Manipulate[Plot[{a*Sin[x], func[x, b]}, {x, 0, 2 Pi},
Epilog -> First[NumberLinePlot[{a Sin[x] <= func[x, b],
a Sin[x] > func[x, b]}, {x, 0, 2 Pi},
PlotStyle -> {Directive[Red, Thick, Arrowheads[{-.05, 0}]],
Directive[Blue, Thick, Arrowheads[{0, .05}]]},
Spacings -> 0] /. Line -> Arrow]],
{a, 1, 10}, {b, 0.5, 10}]

Original answer:
Manipulate[Show[Plot[{a*Sin[x], func[x, b]}, {x, 0, 2 Pi}],
Plot[{ConditionalExpression[0, func[x, b] <= a Sin[x]],
ConditionalExpression[0, func[x, b] >= a Sin[x]]}, {x, 0, 2 Pi},
PlotStyle -> {Directive[Red, Thick, Arrowheads[{0, .05}]],
Directive[Blue, Thick, Arrowheads[{-.05, 0}]]}] /. Line -> Arrow],
{a, 1, 10}, {b, 0.5, 10}]

You can also use a combination of Epilog
and ParametricPlot
with Mesh
options:
Manipulate[Plot[{a*Sin[x], func[x, b]}, {x, 0, 2 Pi},
Epilog -> First[ParametricPlot[{x, 0}, {x, 0, 2 Pi},
MeshFunctions -> {a Sin[#] - func[#, b] &}, Mesh -> {{0}},
MeshShading -> {Directive[Red, Thick, Arrowheads[{-.05, 0}]],
Directive[Blue, Thick, Arrowheads[{0, .05}]]}] /. Line -> Arrow]],
{a, 1, 10}, {b, 0.5, 10}]
Sin[x]
greater thanbx
? Fora=1
andb=0.5
, at $x=1$Sin[x]>bx
at $x=4$Sin[x]<bx
. At the intersectionSin[x]==bx
. At which point ofx
are you evaluating at? $\endgroup$ – I should change my Username Jul 7 '17 at 9:12