# Align plots with a shift

I've got three plots combined through Overlay:

Overlay[Table[Plot[PDF[NormalDistribution[0, ss], x], {x, -2, 2},
Axes -> {True, False},
Ticks -> None,
PlotRange -> {All, {0, 2}},
ImageSize -> 200],
{ss, {.2, .5, 1}}]]


Now I'd like to obtain something like this:

I tried to achieve that with the Alignment option but to no avail. Thanks in advance for any ideas.

-
Offset might be what you need. –  Verbeia Jan 16 '14 at 19:26
Is this a one-shot deal? If so, just using drawing tools to combine/align is easiest. Otherwise, Inset or ImageCompose are possibilities. –  ciao Jan 16 '14 at 23:13

Maybe not exactly what you were looking for, but this reminded me of a plotting function I made recently, so here it is.

data = Table[{x,
PDF[NormalDistribution[0, ss], x]}, {ss, {1, .5, .2}}, {x, -2,
2, .01}];
data2polygon[list_, offset_] :=
Module[{forward, backward, zeros, yvalues},
zeros = PadRight[{}, Length[list]];
yvalues = PadRight[{}, Length[list], offset];
forward = Transpose[{list[[All, 1]], yvalues, list[[All, 2]]}];
backward = Transpose[{Reverse[list[[All, 1]]], yvalues, zeros}];
Polygon[Join[forward, backward]]];
ptable = Table[
Graphics3D[{Opacity[0.25], data2polygon[data[[n]], n]}], {n,
Length[data]}];
Show[ptable, Boxed -> False]


When the result is spit out, it looks like this

But then you can change the viewing angle with your mouse and you end up with something similar to what you asked for:

And then you could take it farther to add more plots,

data = Table[{x, PDF[NormalDistribution[0, ss], x]}, {ss,
1, .1, -.1}, {x, -2, 2, .01}];
ptable = Table[
Graphics3D[{Opacity[0.55], Red, EdgeForm[Blue],
data2polygon[data[[n]], .7 n]}], {n, Length[data]}];
Show[ptable, Boxed -> False]


edit: It would be nice to find a way to automatically label the different plots in that last image, I may try to do so sometime in the future.

-

This is the same as your code plus the horizontal lines and some formatting:

cornflowerBlue = RGBColor[0.392193, 0.584307, 0.929395];
plots =
Table[
Show[
Graphics[{LightGray, Thick,  Line[{{-2, 0}, {2, 0}}]}], (* the line *)
Plot[PDF[NormalDistribution[0, ss], x], {x, -2, 2}, PlotRange -> All, PlotStyle -> Directive[Thick, cornflowerBlue]]],
{ss, {.2, .5, 1}}]


Now we translate each graphic as we assemble them:

Graphics@MapThread[
Translate,
{First /@ plots,
Accumulate@ConstantArray[0.5 {1, -1}, Length[plots]] (* generate the shifts *)
}]


Modify the 0.5 {1, -1} translation vector to control the relative translation of the figures.

There are two key points:

• extracting the graphics primitives from the output of Plot using First
• using Translate to position them

An advantage of this method is that unlike Overlay it generates an actual Graphics object which is easier to export to the correct size.

-
This cobalt looks great but I can't reproduce it, it is significantly darker on my screen :/. –  Kuba Feb 21 '14 at 0:34
@Kuba Fixed now. I tend to use the NamedColorsPalette[] from the SciDraw package. I think these may have come with some older version of Mathematica, but I'm not sure. –  Szabolcs Feb 21 '14 at 0:56
@Kuba Yes, it's this one where the colours came from, I think the NamedColors package just added a palette to make it easy to choose a pretty one. –  Szabolcs Feb 21 '14 at 0:58
Indeed, thank you ;) –  Kuba Feb 21 '14 at 1:01

Seems like a combination of Inset/Offset is the way to go:

plotTab =
Table[Plot[PDF[NormalDistribution[0, ss], x], {x, -2, 2},
Axes -> {True, False},
Ticks -> None,
PlotRange -> {All, {0, 2}},
ImageSize -> 200],
{ss, {.2, .5, 1}}];

Graphics[Table[
{Inset[plotTab[[ii]], Offset[{10*ii, -10*ii}, {0, 0}]]},
{ii, Length[plotTab]}]]


-