0

I want to create two figures, side by side, each with an independent Locator.

I want to do this using Manipulate, because I can easily use information from each Locator in both plots.

This answer did not use Manipulate, but rather a bunch of Dynamic statements inside a DynamicModule. This is problematic for me, because my actual use case involves a bunch of graphics objects that depend on each locator, and I don't understand how to combine them with the locators while keeping them dynamic.

If this request isn't possible using Manipulate, that would also be helpful to know. Then I'll have to ask a question closer to my actual problem.

Thanks

1 Answers1

2

Try following:

st = Sequence[AspectRatio -> 1, PlotRange -> {-10, 10}];
Manipulate[
 Row@{
   Plot[a x, {x, 0, 10}, Evaluate@st],
   Plot[b x, {x, 0, 10}, Evaluate@st]},
 {a, -1, 1, 0.1}, {b, -1, 1, 0.1}]

enter image description here

UPD: Two Locators work a bit slowly but try this:

Manipulate[
 GraphicsRow@{
   Plot[a[[2]]/a[[1]] Sin@x, {x, a[[1]]/100, 1 + 2 a[[1]]/100}, 
    PlotRange -> {{0, 20}, {-1, 1}}, ImageSize -> 480],
   Spacer[50],
   Plot[(2 b[[2]])/b[[1]] Sin@x, {x, b[[1]]/100, 1 + 2 b[[1]]/100}, 
    PlotRange -> {{0, 20}, {-1, 1}}, ImageSize -> 480]
   }
 , {a, Locator}, {b, Locator}, LocalizeVariables -> False]

enter image description here

Keep in mind, that GraphicsRow makes the common graphical pane for both plots and coordinates of Locators are in pixels.

Rom38
  • 5,129
  • 13
  • 28
  • Thanks, but these are sliders, and not locators. I'm specifically asking to put a locator in each figure. – Eric Hester Apr 22 '22 at 15:51
  • @EricHester, look an update – Rom38 Apr 23 '22 at 08:18
  • Nice! This does work, though I don't understand it. How are a and b assigned to each plot? Also, it is rather slow. – Eric Hester Apr 25 '22 at 16:14
  • @EricHester, The a and b are in joint coordinate system of the whole graphics row (the origin is in the left corner) . You can re-scale these coordinates to the plot-related systems using the pixel coordinates of the each zero-point and corresponding end-points of the axes. – Rom38 Apr 26 '22 at 06:27