2
$\begingroup$

In mathematica 12.0, the following code

Show[
 {Plot[PDF[NormalDistribution[i, 1], x] Exp[-Sqrt[i]/4] /. 
      i -> Range[1, 3, 2] // Evaluate, {x, -3, 8}, PlotRange -> All, 
     Axes -> None, PlotStyle -> {Black, Gray}],
   Table[Plot[
     PDF[NormalDistribution[i, 1], x] Exp[-Sqrt[i]/4] /. 
       i -> Range[1, 3, 2] // Evaluate, {x, k, k + 1}, 
     PlotRange -> Full, Filling -> Axis, Axes -> None,
     PlotStyle -> {ColorData[10][4 + k], 
       Darker[ColorData[10][4 + k], 0.3]}], {k, -3, 5}]} // Flatten,
 PlotRange -> {0, 1/3}]

produces the following plot

enter image description here

It seems to me the (square like white) gap near the bottom is unexpected (?)

$\endgroup$
4
$\begingroup$

The issue caused by differing vertical positions of Axis across plots with filling.

plotswithfilling = Table[
  Plot[PDF[NormalDistribution[i, 1], x] Exp[-Sqrt[i]/4] /. 
      i -> Range[1, 3, 2] // Evaluate, {x, k, k + 1}, 
    PlotRange -> Full, Filling -> Axis, Axes -> None, 
    PlotStyle -> {ColorData[10][4 + k], 
      Darker[ColorData[10][4 + k], 0.3]}], {k, -3, 5}];

Options[#, AxesOrigin] & /@ plotswithfilling // Column

enter image description here

Two easy fixes: (1) Change Filling -> Axis to Filling -> 0 or (2) add the option AxesOrigin -> {Automatic, 0}

to get

enter image description here

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ When phrased like this is makes perfect sense :-) Sometimes mathematica is too smart! $\endgroup$ – chris Jun 25 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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