# \[?\] Put 2 different plots inside a manipulation?

**URL:** <https://community.wolfram.com/t/put-2-different-plots-inside-a-manipulation/10712>\
**Category:** Questions\
**Tags:** graphics-and-visualization, interface-construction\
**Created:** [June 16, 2017, 5:56pm UTC](https://community.wolfram.com/t/put-2-different-plots-inside-a-manipulation/10712 "2017-06-16T17:56:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mluntz](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mluntz](https://community.wolfram.com/u/mluntz)\
**Post date:** [June 16, 2017, 5:56pm UTC](https://community.wolfram.com/t/put-2-different-plots-inside-a-manipulation/10712/1 "2017-06-16T17:56:27Z")

</div>

I would like to have a notebook with 2 different kinds of plots inside a manipulation, in which the control for the manipulation uses locators linked to one of the plots. A simple example of something close to what I desire that will work is shown in the code below, but only one of the plots is inside the manipulate. The example plots a pair of sinusoids where the amplitudes and phases are controlled with the mouse by moving a variable around the complex plane.

```
Dynamic[Plot[{Sqrt[w[[1, 1]]^2 + w[[1, 2]]^2] Sin[
     2 \[Pi] t + ArcTan[w[[1, 2]]/w[[1, 1]]]], 
   Sqrt[w[[2, 1]]^2 + w[[2, 2]]^2] Sin[
     2 \[Pi] t + ArcTan[w[[2, 2]]/w[[2, 1]]]]}, {t, 0, 1}, 
  PlotRange -> {{0, 1}, {-3, 3}}]]

Manipulate[w = p; 
 ListPlot[p, 
  PlotRange -> {{-2, 2}, {-2, 2}}], {{p, {{-1, -1}, {1, 1}}}, 
  Locator}]

```

But what I would really prefer is to do the same calculations with something like the following, which does not work. Is there anything similar to this second approach that does work?

```
Manipulate[w = p; 
 GraphicsRow[{Plot[{Sqrt[w[[1, 1]]^2 + w[[1, 2]]^2] Sin[
       2 \[Pi] t + ArcTan[w[[1, 2]]/w[[1, 1]]]], 
     Sqrt[w[[2, 1]]^2 + w[[2, 2]]^2] Sin[
       2 \[Pi] t + ArcTan[w[[2, 2]]/w[[2, 1]]]]}, {t, 0, 1}, 
    PlotRange -> {{0, 1}, {-3, 3}}], 
   ListPlot[p, 
    PlotRange -> {{-2, 2}, {-2, 2}}]}], {{p, {{-1, -1}, {1, 1}}}, 
  Locator}]

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [June 16, 2017, 6:20pm UTC](https://community.wolfram.com/t/put-2-different-plots-inside-a-manipulation/10712/2 "2017-06-16T18:20:58Z")

</div>

For this particular example a 2D slider works quite well:

```
Manipulate[
 Plot[{Norm[p] Sin[2 \[Pi] t + ArcTan[p]], 
   Norm[p] Sin[2 \[Pi] t + ArcTan[p]]}, {t, 0, 1}, 
  PlotRange -> {{0, 1}, {-3, 3}}],
 {{p, {0, 0}}, {-2, -2}, {2, 2}}]

```

A variation:

```
Manipulate[
 Row[{Plot[{Norm[p] Sin[2 \[Pi] t + ArcTan[p]], 
     Norm[p] Sin[2 \[Pi] t + ArcTan[p]]}, {t, 0, 1}, 
    PlotRange -> {{0, 1}, {-3, 3}}],
   Graphics[Locator[Dynamic@p], PlotRange -> 2, Frame -> True]}],
 {{p, {0, 0}}, {-2, -2}, {2, 2}, ControlType -> None}]

```

---

<div class="post-metadata">

**Author:** ![mluntz](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mluntz](https://community.wolfram.com/u/mluntz)\
**Post date:** [June 16, 2017, 7:23pm UTC](https://community.wolfram.com/t/put-2-different-plots-inside-a-manipulation/10712/3 "2017-06-16T19:23:12Z")

</div>

Gianluca,

Thanks for the suggestion. That has given me some things to think about. I guess I don’t really understand your solution so maybe you can explain it some. When I ran your suggestion I only ended up with a single control, but in spite of that the single slider seemed to control both sinusoids in some unexplained way. I expected to have a pair of controls, each controlling its own sinusoid. Just to let you know, this is just a simplifying example for my real problem. What I am really trying to do is to manually move around pole/zero pairs of an all-pass filter to see their effect on compensating group delay of another filter. There will likely be several pole/zero pairs needed to compensate the filter, thus multiple controls required.

BTW, thanks for cleaning up my original code. I was so focused on the problem of controls that I wasn’t even thinking about the example function I wanted to plot.

Mike

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [June 16, 2017, 9:35pm UTC](https://community.wolfram.com/t/put-2-different-plots-inside-a-manipulation/10712/4 "2017-06-16T21:35:15Z")

</div>

I made my share of mistakes with my first attempt. This may be more like what you want, with two distinct controls and correct syntax for `ArcTan`:

```
Manipulate[
 Row[{Plot[{Norm[p] Sin[2 \[Pi] t + ArcTan @@ p], 
     Norm[q] Sin[2 \[Pi] t + ArcTan @@ q]}, {t, 0, 1}, 
    PlotRange -> {{0, 1}, {-3, 3}}, PlotStyle -> {Red, Blue}, 
    ImageSize -> Medium],
   Spacer[20], 
   Graphics[{Locator[Dynamic@p, Background -> Red], 
     Locator[Dynamic@q, Background -> Blue]}, PlotRange -> 2, 
    Frame -> True]}],
 {{p, {1, 1}}, {-2, -2}, {2, 2}, ControlType -> None},
 {{q, -{1, 1}}, {-2, -2}, {2, 2}, ControlType -> None}]

```
