# How to change color of LocatorPane Dynamic point constrained to LogLogPlot line - when point is above set value?

In the following LogLogPlot, I'd like to have the Dynamic[pt] color change from Purple to Blue - when above the Purple horizontal line - and change from Purple to Red when below the line. So far, Directive[Purple] initializes the color:

DynamicModule[{pt = {-9., -55.2}}, LocatorPane[Dynamic[pt],
LogLogPlot[1/x^3, {x, 10^-12, 10^8},
Epilog -> {
{PointSize[Large], Directive[Purple],
Point[Dynamic[{First[pt], 1/Exp[First@pt]^3 // Log}]]},
{Inset[Style["\[LongDash]\[LongDash]\[LongDash]\[LongDash]", Bold, Purple], {-9,
26.5}]}
},
AxesOrigin -> {0, 0}, AspectRatio -> 1, ImageSize -> {520, 400}]
]]


However, attempts at using If[...] logic, or the following Which[...] intervals logic, returns the Error message: "Which is not a graphics directive":

Directive[Which[
Dynamic[pt] == {Interval[{.0001, 10^-12}],
Interval[{10^-9, 10^33}]}, Blue,
Dynamic[pt] == {Interval[{.0001, .001}], Interval[{10^-11, 10^-9}]},
Purple,
Dynamic[pt] == {Interval[{.001, 10^8}], Interval[{10^-11, 10^-25}]},
Red]]


Also, perhaps I should post this as a separate question, but it would be really tight if the Locator itself were constrained to the x axis.

• btw, is the original one laggy for you too, or is it only me? – Kuba Nov 22 '18 at 23:02
• Nope, neither the original, or @kglr solution, or now my embellished version have any noticeable lag - running on a 2017 MacBook. That is something on my mind though - since I'm working on a loaded up Demonstration Project wondering how well it will work on other systems. – ehounder Nov 23 '18 at 1:32

(1) You can use the second argument of Dynamic to restrict the locator to the horizontal axis, and (2) you can use Dynamic@Directive[If[First[pt] <= -9, Purple, Red]] to change the color of the point based on the locator position:
DynamicModule[{pt = {-9., -55.2}},