Message Boards Message Boards

Assign locator points to a specific plot?

dynamic interactivity graphics and visualization wolfram language

The goal is to create a user defined function with Locator points and then to plot several results based on the user entered function. The problem is that I haven't determined how to tell the Locator points which plot they should appear on. Tried using LocatorPane, and that did results in the Locator points appearing as expected, but a second set of locator points appears on the other plot. And this second set is the one that the user should control. When working properly, there should be only one copy of Locator points and they should appear on the specified plot.

Also, the LocatorAutoCreate appears to not be working. Clicking in an empty area of the graph should make a new point, but instead it is moving one of the existing points.

In the example below, there are two plots. The upper plot shows f(x) and the lower plot shows the derivative of the f(x). The function f(x) is defined via the locator points.

Any comments or suggestions are welcome.

 ptsExtended = Prepend[Append[Sort[ptsAll], {1.5, 1}], {-2, 0}] ;
 fpts   = Interpolation[ptsExtended, InterpolationOrder -> 1];
 dfpts = Derivative[1][fpts];
 plotf   =   Plot[fpts[x], {x, 0, 1},  PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1} }, PlotLabel -> Style["f(x)", Bold, 12]];
 plotdf =   Plot[dfpts[x], {x, 0, 1}, PlotRange -> {{-0.1, 1.1}, {-2, 4}},  PlotLabel -> Style["df(x)", Bold, 12]];
 Grid[{{LocatorPane[ptsAll, plotf]}, {plotdf}}]
 (*list of controls*)
 {{ptsAll, initPtsAll}, ControlType -> Locator, LocatorAutoCreate -> True}
 (*other details*)
 , TrackedSymbols :> {ptsAll}
 , Initialization :> (
   initPtsAll = {{0, 0}, {0.25, 0.25}, {0.5, 0.6}, {0.75, 0.85}, {1,1} };
 , SynchronousUpdating -> False
POSTED BY: Robert McHugh
11 days ago

Group Abstract Group Abstract