3
$\begingroup$

I am trying to find out, how to properly use a locator continuously within manipulate and a grid of graphics. I have the following example

Manipulate with grid of graphics

out of this code

Manipulate[
 pltrng = {{-2, 2}, {-2, 2}};
 Grid[{
   {Graphics[{col, Rectangle[]}], 
    LocatorPane[Dynamic@p, 
     Graphics[{Red, Rectangle[{-l/2, -1}, {l/2, 1}]}, 
      PlotRange -> pltrng], LocatorAutoCreate -> True]}
   , {p, Plot[p[[1]] + p[[2]]*x, {x, 0, 1}, PlotRange -> {-2, 2}]}
   }]
 , {{p, {1, 1}}, None}
 , {l, 1, 2}
 , {col, Green}
 ]

I want to be able to move around only the graphic with the red rectangle (the locator HAS TO BE in this specific graphic within the grid, not in the left upper corner graphic), extract the current values and use the current values in other evaluations (e.g., for immediate updates of the function plotted in the lower right corner). That seems fine but I dont know why I am not able to move continuously with the locator (at least I can not move continuously on my laptop, Windows 10, Mathematica 10.3). Can you move continuously? If not, any ideas how to solve this? I am sure I am forgetting something very trivial here. Thanks!

$\endgroup$
0
3
$\begingroup$

Wrap p and Plot[...] in the last row of your grid with Dynamic:

Manipulate[pltrng = {{-2, 2}, {-2, 2}};
 Grid[{{Graphics[{col, Rectangle[]}],  
        LocatorPane[Dynamic@p, Graphics[{Red, Rectangle[{-l/2, -1}, {l/2, 1}]}, 
           PlotRange -> pltrng], LocatorAutoCreate -> True]}, 
  {Dynamic@Column@p, 
   Dynamic@Plot[p. {1, x}, {x, 0, 1}, Evaluated -> True, PlotRange -> {-2, 2}]}}], 
 {{p, {{1, 1}}}, None}, {l, 1, 2}, {col, Green}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Awesome! Thank you! $\endgroup$ Apr 6 '16 at 20:10
  • $\begingroup$ @MauricioLobos, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Apr 6 '16 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.