Re: Re: Re: Locator question
- To: mathgroup at smc.vnet.net
- Subject: [mg79525] Re: [mg79452] Re: [mg79433] Re: Locator question
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sat, 28 Jul 2007 05:39:48 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <f86r55$pc7$1@smc.vnet.net> <200707250930.FAA26363@smc.vnet.net> <f89pve$5jn$1@smc.vnet.net> <200707261030.GAA09683@smc.vnet.net> <12053562.1185538119591.JavaMail.root@m35> <op.tv4rezijqu6oor@monster.gateway.2wire.net>
- Reply-to: murray at math.umass.edu
Under Windows XP with Mathematica 5.0.1, and with the version of trackPointOnPlot nearest the top of my posting, I see only one locator! DrMajorBob wrote: > That code gives me two locators, neither of them on the curve. One can't > be "grabbed", but it moves when I move the other one. If I move the > second locator to the curve, the other also moves to the curve, at > another point (but sometimes beyond the left limit of the plot). > > Bizarro! > > Am I the only one seeing this? > > Bobby > > On Fri, 27 Jul 2007 04:48:07 -0500, Murray Eisenberg > <murray at math.umass.edu> wrote: > >> Very nice! An observation and a question: >> >> 1. Probably it would be more reasonable that the third, optional, >> argument be not an {x,y} point, but instead the x-coordinate of that >> point, since the point is supposed to be on the graph anyway. The >> modification for that is trivial: >> >> trackPointOnPlot[f_, {a_, b_}, strt_: Automatic] := >> Module[{start = strt /. Automatic -> a}, >> DynamicModule[{p = {start, f[start]}}, >> Column[{LocatorPane[Dynamic[p, (p = {First@#, f[First@#]}) &], >> Plot[f[x], {x, a, b}]], Dynamic[p]}]]] >> >> 2. Where/how did you discover the "trick" of using Automatic as a >> default value for an argument? I don't recall seeing that before. >> >> Albert wrote: >>> ...The following is my attempt to solve your issue, it only uses one >>> definition, but introduces some extra code... >>> >>> trackPointOnPlot[f_, {a_, b_}, strt_: Automatic] := >>> Module[{start = strt /. Automatic -> {a, f[a]}}, >>> DynamicModule[{p = start}, >>> Column[{LocatorPane[Dynamic[p, (p = {First@#, f[First@#]}) &], >>> Plot[f[x], {x, a, b}]], Dynamic[p]}]] >>> ] >> >> Of course, per your suggestion, a simpler way but now using only the >> x-coordinate as third, optional, argument is: >> >> trackPointOnPlot[f_, {a_, b_}, start_] := >> DynamicModule[{p = {start, f[start]}}, >> Column[{LocatorPane[Dynamic[p, (p = {First@#, f[First@#]}) &], >> Plot[f[x], {x, a, b}]], Dynamic[p]}]] >> >> trackPointOnPlot[f_, {a_, b_}] := trackPointOnPlot[f, {a, b}, a] >> > > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- Re: Locator question
- From: Albert <awnl@arcor.net>
- Re: Locator question
- From: Albert <awnl@arcor.net>
- Re: Locator question