-1

Why does

pPost[1, k_, p_: 2/3, p1_: 1/3, p2_: 2/3] := 
  (p p1^k (1 - p1)^(3 - k))/(p p1^k (1 - p1)^(3 - k) + (1 - p) p2^k (1 - p2)^(3 - k));
pPost[2, k_, p_: 2/3, p1_: 1/3, p2_: 2/3] := 
  ((1 - p) p2^k (1 - p2)^(3 - k))/(p p1^k (1 - p1)^(3 - k) + (1 - p) p2^k (1 - p2)^(3 - k));

Manipulate[
  Show[
    Plot[pPost[1, k, p, p1, p2], {k, 0, 3},
      PlotStyle -> {Dashed, Thin}, 
      PlotRange -> {All, {0, 1}}, 
      Ticks -> {{0, 1, 2, 3}, Automatic}],
    ListPlot[
      {{#, pPost[1, #, p, p1, p2]} & /@ Range[0, 3], 
       {#, pPost[2, #, p, p1, p2]} & /@ Range[0, 3]},
      PlotStyle -> {Green, Red}, 
      Filling -> Axis]],
  {{p, 2/3}, 0, 1},
  Delimiter,
  {{p1, 1/3}, 0, 1}, 
  {{p2, 2/3}, 0, 1}]

produce plots where the filling "disconnects" from the axis for some values of the Manipulate parameters?


Try p=0.75, p1=0.7, p2=0.6:

or (weirder) p=p1=p2=0.5

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
orome
  • 12,819
  • 3
  • 52
  • 100

1 Answers1

2

While the order of the plots in Show makes difference, it is not the whole story. By default, many options are set automatically at the time of execution. In particular, PlotRange and AxesOrigin. The settings for Plot and ListPlot are determined separately since they are evaluated separately. This much I think can be inferred from the documentation, although not "easily."

When the ListPlot has a narrow plot height, the axes origin is moved up closer to the points. This can be controlled by setting PlotRange as mentioned in the comments. I would prefer to control it by setting

 AxesOrigin -> {0, 0}

in ListPlot to force the axes to always be at {0, 0}, and let the PlotRange be determined automatically.

Often in practice, to get two or more independent plots to look right when combined, automatically determined options often have to be set explicitly in all plots.

Michael E2
  • 235,386
  • 17
  • 334
  • 747