Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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}]
share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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?

share|improve this answer
    
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}] –  Michael E2 Oct 3 '13 at 20:59
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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