Skip to main content
added 489 characters in body
Source Link

Murta's solution works nicely, but there is a way to do what is desired without the fuss of using Show[] and separate instances of Plot[]. Witness the following:

With[{dist = PDF[NormalDistribution[5, 1], #] &1]], l = 5},
     Plot[{ConditionalExpression[dist[x], x < l], dist[x]}, {x, 0, 10}, 
          Epilog -> {Orange, Line[{{l, 0}, {l, dist @ l}}]}, 
          Filling -> {1 -> Axis}, PlotRange -> {{0, 10}, All}, 
          PlotLabel -> Style[StringForm["l=`1`", NumberForm[dist @ N @ l, {∞, 2}]], 20],
          PlotStyle -> ColorData[1, 1]]]

filling under the normal curve

The key here is the tandem use of the specifications in the Filling option to restrict the filling to a single curve, and ConditionalExpression[] to restrict the filling domain.


The Wizard reports the following variation that is useful to people who don't have ConditionalExpression[] handy:

With[{dist = PDF[NormalDistribution[5, 1]], l = 5}, 
     Plot[{If[x < l, dist[x]], dist[x]}, {x, 0, 10}, 
          Epilog -> {Orange, Line[{{l, 0}, {l, dist @ l}}]}, Filling -> {1 -> Axis}, 
          PlotLabel -> Style[StringForm["l=`1`", NumberForm[dist @ N @ l, {∞, 2}]], 20],
          PlotRange -> All, PlotStyle -> ColorData[1, 1]]]

Murta's solution works nicely, but there is a way to do what is desired without the fuss of using Show[] and separate instances of Plot[]. Witness the following:

With[{dist = PDF[NormalDistribution[5, 1], #] &, l = 5},
     Plot[{ConditionalExpression[dist[x], x < l], dist[x]}, {x, 0, 10}, 
          Epilog -> {Orange, Line[{{l, 0}, {l, dist @ l}}]}, 
          Filling -> {1 -> Axis}, PlotRange -> {{0, 10}, All}, 
          PlotLabel -> Style[StringForm["l=`1`", NumberForm[dist @ N @ l, {∞, 2}]], 20],
          PlotStyle -> ColorData[1, 1]]]

filling under the normal curve

The key here is the tandem use of the specifications in the Filling option to restrict the filling to a single curve, and ConditionalExpression[] to restrict the filling domain.

Murta's solution works nicely, but there is a way to do what is desired without the fuss of using Show[] and separate instances of Plot[]. Witness the following:

With[{dist = PDF[NormalDistribution[5, 1]], l = 5},
     Plot[{ConditionalExpression[dist[x], x < l], dist[x]}, {x, 0, 10}, 
          Epilog -> {Orange, Line[{{l, 0}, {l, dist @ l}}]}, 
          Filling -> {1 -> Axis}, PlotRange -> {{0, 10}, All}, 
          PlotLabel -> Style[StringForm["l=`1`", NumberForm[dist @ N @ l, {∞, 2}]], 20],
          PlotStyle -> ColorData[1, 1]]]

filling under the normal curve

The key here is the tandem use of the specifications in the Filling option to restrict the filling to a single curve, and ConditionalExpression[] to restrict the filling domain.


The Wizard reports the following variation that is useful to people who don't have ConditionalExpression[] handy:

With[{dist = PDF[NormalDistribution[5, 1]], l = 5}, 
     Plot[{If[x < l, dist[x]], dist[x]}, {x, 0, 10}, 
          Epilog -> {Orange, Line[{{l, 0}, {l, dist @ l}}]}, Filling -> {1 -> Axis}, 
          PlotLabel -> Style[StringForm["l=`1`", NumberForm[dist @ N @ l, {∞, 2}]], 20],
          PlotRange -> All, PlotStyle -> ColorData[1, 1]]]
Source Link

Murta's solution works nicely, but there is a way to do what is desired without the fuss of using Show[] and separate instances of Plot[]. Witness the following:

With[{dist = PDF[NormalDistribution[5, 1], #] &, l = 5},
     Plot[{ConditionalExpression[dist[x], x < l], dist[x]}, {x, 0, 10}, 
          Epilog -> {Orange, Line[{{l, 0}, {l, dist @ l}}]}, 
          Filling -> {1 -> Axis}, PlotRange -> {{0, 10}, All}, 
          PlotLabel -> Style[StringForm["l=`1`", NumberForm[dist @ N @ l, {∞, 2}]], 20],
          PlotStyle -> ColorData[1, 1]]]

filling under the normal curve

The key here is the tandem use of the specifications in the Filling option to restrict the filling to a single curve, and ConditionalExpression[] to restrict the filling domain.