0
$\begingroup$

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

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ Thanks, but these are sliders, and not locators. I'm specifically asking to put a locator in each figure. $\endgroup$ Apr 22, 2022 at 15:51
  • $\begingroup$ @EricHester, look an update $\endgroup$
    – Rom38
    Apr 23, 2022 at 8:18
  • $\begingroup$ Nice! This does work, though I don't understand it. How are a and b assigned to each plot? Also, it is rather slow. $\endgroup$ Apr 25, 2022 at 16:14
  • $\begingroup$ @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. $\endgroup$
    – Rom38
    Apr 26, 2022 at 6:27

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.