How to add/insert a well aligned graphics on top of another one?
I think it may perhaps be easier just to combine plots and modify (e.g. suppress unnecessary frame ticks). I post this as a motivating answer rather than definitive answer. li
is a modified version of OP function:
li[p_, q_, phi_, {l_, u_}] :=
DensityPlot[(If[p > 0, Sin[2 Pi p^2 x]/(2 Pi p^2 x), 1] Cos[
2 Pi p^2 q x + phi/2])^2, {x, -30, 30}, {y, l, u},
AspectRatio -> 0.1, PlotPoints -> {1000, 2}, Frame -> None,
ImageSize -> 600]
Manipulate[
Show[Intensity[0.25, 5, 0], li[0.25, 5, 0, {l, u}]], {l, -1, 0,
Appearance -> "Labeled"}, {{u, -0.5}, -1, 0,
Appearance -> "Labeled"}]
This is a partial solution, using Epilog
and Inset
. It has an alignment problem, especially after we resize the picture by hand inside the Manipulate
box. Also, without resizing the whole, playing with the parameters may give an alignment problem after a while. How to fix this ?
LumIntensity[x_, p_, q_] := (If[p > 0, Sin[2Pi p^2 x]/(2Pi p^2 x), 1]Cos[2Pi p^2 q x])^2
Intensity1[p_, q_] := Inset[
DensityPlot[LumIntensity[x, p, q],
{x, -30, 30}, {y, 0, 1},
ColorFunction -> GrayLevel,
AspectRatio -> 0.1,
Frame -> None,
PlotPoints -> {1000, 2},
ImageSize -> 600],
{0, -0.1}
]
Intensity2[p_, q_] := Plot[
LumIntensity[x, p, q],
{x, -30, 30},
PlotPoints -> 400,
MaxRecursion -> 4,
PlotRange -> {{-30, 30}, {-0.2, 1}},
Axes -> None,
AspectRatio -> 1,
Frame -> True,
Epilog -> Intensity1[p, q],
ImageSize -> {600, 600}
]
Manipulate[
Intensity2[p, q],
{{p, 0.25, Style["Diffraction : p", 12]}, 0, 0.5, 0.01,
ImageSize -> Large, Appearance -> "Labeled"},
{{q, 1, Style["Interference : q", 12]}, 1, 10, 0.01,
ImageSize -> Large, Appearance -> "Labeled"},
ControlPlacement -> Bottom,
FrameMargins -> None
]
Preview :
So how can I make the bottom graphics always well aligned with the graphics above it, even after we resive the whole by hand ?