3
$\begingroup$

I have the following code that produces a plot of a Normal distribution:

Plot[Table[PDF[NormalDistribution[μ, 3], x], {μ, {4}}] // Evaluate, {x, -15, 15}, 
 Filling -> None, Axes -> {True, True}, Ticks -> None, 
 PlotStyle -> {RGBColor[0.368417, 0.506779, 0.709798],
  RGBColor[0.880722, 0.611041, 0.142051]}]

How do I fill to the left of the y-axis only?

$\endgroup$
0

2 Answers 2

4
$\begingroup$

How about this:

 f[x_] := PDF[NormalDistribution[4, 3], x]

Show[Plot[f[x], {x, -15, 15}, Ticks -> None, 
  PlotStyle -> {RGBColor[0.880722, 0.611041, 0.142051]}], 
 Plot[f[x], {x, -15, 0}, 
  PlotStyle -> {RGBColor[0.880722, 0.611041, 0.142051]}, 
  PlotRange -> All, Filling -> Axis]]

enter image description here

$\endgroup$
4
$\begingroup$

ConditionalExpression combined with the option Filling:

Plot[{PDF[NormalDistribution[4, 3], x], ConditionalExpression[0, x <= 0]}, {x, -15, 15}, 
  Ticks -> None, 
  PlotStyle -> {RGBColor[0.880722, 0.611041, 0.142051], None}, 
  Filling -> {1 -> {2}}] 

enter image description here

Plot[Evaluate @ Append[Table[PDF[NormalDistribution[μ, 3], x], {μ, {3, 4, 5}}],
   ConditionalExpression[0, x <= 0]] , {x, -15, 15},  
 Filling -> {1 -> {4}, 2 -> {4}, 3 -> {4}},
 Ticks -> None, 
 PlotStyle -> Append[ColorData[97] /@ {1, 2, 3}, None], 
 PlotLegends -> ("μ = " <> # & /@ {"3", "4", "5"})]

enter image description here

$\endgroup$

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