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: overlaid plots with a shift

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

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

3 Answers 3


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

cornflowerBlue = RGBColor[0.392193, 0.584307, 0.929395];
plots = 
    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:

  {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.

  • $\begingroup$ This cobalt looks great but I can't reproduce it, it is significantly darker on my screen :/. $\endgroup$
    – Kuba
    Feb 21, 2014 at 0:34
  • $\begingroup$ @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. $\endgroup$
    – Szabolcs
    Feb 21, 2014 at 0:56
  • $\begingroup$ @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. $\endgroup$
    – Szabolcs
    Feb 21, 2014 at 0:58
  • $\begingroup$ Indeed, thank you ;) $\endgroup$
    – Kuba
    Feb 21, 2014 at 1:01

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, 
Show[ptable, Boxed -> False]

When the result is spit out, it looks like this

enter image description here

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

enter image description here

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]

enter image description here

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.


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}}];

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

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.