Re: Why are both locators moving?
- To: mathgroup at smc.vnet.net
- Subject: [mg115258] Re: Why are both locators moving?
- From: John Fultz <jfultz at wolfram.com>
- Date: Wed, 5 Jan 2011 05:48:09 -0500 (EST)
Looks like a bug to me. You can work around it, though, and even make the code a bit less tortured in the process, by using LocatorPane[]. p1 == {0, 0} p2 == {0, 1} LocatorPane[Dynamic[{p1, p2}], Dynamic[a == p1;(*condition 1*) Show[Plot[Cos[b], {b, 1, 2}],(*condition 2*) Graphics[Line[{{0, 0}, {1, 1}}]], PlotRange -> {{-10, 10}, {-1, 1}}, Axes -> True, AspectRatio -> 1]]] Dynamic[{p1, p2}] Sincerely, John Fultz jfultz at wolfram.com User Interface Group Wolfram Research, Inc. On Tue, 4 Jan 2011 18:49:50 -0500 (EST), Dims wrote: > In the code below I expect that locators can be moved independently, > but actually locator p1 causes locator p2 to move too if both > conditions occure: > > 1) any "Plot" instruction presents within Show > 2) a==p1; presents within Dynamic > > p1 == {0, 0} > p2 == {0, 1} > Dynamic[ > a == p1; (* condition 1 *) > Show[ > Plot[Cos[b],{b,1,2}], (* condition 2 *) > Graphics[Line[{{0, 0}, {1, 1}}]], > Graphics[Locator[Dynamic[p1]]], > Graphics[Locator[Dynamic[p2]]], > PlotRange -> {{-10, 10}, {-1, 1}}, Axes -> True, AspectRatio -> 1 > ] > ] > > My question is: why? Is it a bug or by-design behavior? Where is the > value for p2 assigned? > > How to make both locators move independently along with plot?