5
$\begingroup$

In this simplified code below, I'd like to display two plots within Manipulate, and use the Locator controltype to set the value of x relative to its position within the first plot only. With the Print[x] command inserted it is obvious that the locator is using the coordinates of the entire graphics plane.

Manipulate[
 Print[x];
 GraphicsRow[{ListLinePlot[{x, {0, 0}}, 
    PlotRange -> {{0, 2}, {0, 2}}], 
   ListLinePlot[{x, {2, 2}}, 
    PlotRange -> {{0, 2}, {0, 2}}]}], {{x, {0, 0}, {2, 2}}, 
  ControlType -> Locator}]
$\endgroup$

2 Answers 2

5
$\begingroup$

Just replace GraphicsRow to Row!

Manipulate[
 Row@{ListLinePlot[{x, {0, 0}}, PlotRange -> {{0, 2}, {0, 2}}, ImageSize -> 200], 
   ListLinePlot[{x, {2, 2}}, PlotRange -> {{0, 2}, {0, 2}}, ImageSize -> 200]}, 
 {{x, {0, 0}, {2, 2}}, Locator}]

enter image description here

Also instead of ControlType -> Locator you can use just Locator.

P.S. Does anybody know how to choose the second plot?

$\endgroup$
1
  • $\begingroup$ To choose the second plot, The only way I could figure out was to explicitly construct the LocatorPane around the second plot. Otherwise it seems to automatically pick the first Graphics it finds. E.g.: Manipulate[ Row@{Dynamic@ ListLinePlot[{x, {0, 0}}, PlotRange -> {{0, 2}, {0, 2}}, ImageSize -> 200], LocatorPane[Dynamic@x, Dynamic@ListLinePlot[{x, {2, 2}}, PlotRange -> {{0, 2}, {0, 2}}, ImageSize -> 200]]}, {{x, {0, 0}, {2, 2}}, ControlType -> None}] $\endgroup$
    – Michael E2
    Oct 3, 2013 at 20:59
3
$\begingroup$

Using LocatorPane we can do this:

DynamicModule[{pt},
  GraphicsRow[{
    LocatorPane[Dynamic[pt], Dynamic@ListLinePlot[{{0, 0}, pt},
          PlotRange -> {{0, 2}, {0, 2}}]],
    Dynamic@ListLinePlot[{{2, 2}, pt}, PlotRange -> {{0, 2}, {0, 2}}]      
   }]]

locators

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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