Message Boards Message Boards

0
|
4009 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Assign locator points to a specific plot?

Posted 8 years ago

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.

Manipulate[
 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
 ]
Attachments:
POSTED BY: Robert McHugh
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract