3

For plots like the one shown below, what is the syntax for adding filling between particular lines and the axis, but only in the negative region:

enter image description here

user120911
  • 2,655
  • 9
  • 18

2 Answers2

3

Here's one way:

Plot[{(x - 1)^2 - 1/2, 0}, {x, 0, 3}, PlotStyle -> {Blue, None}, 
 Filling -> {2 -> {{1}, {None, LightGray}}}]

Plot filled only below axis

murray
  • 11,888
  • 2
  • 26
  • 50
3

Try

Plot[{Cos[x], Sin[x] + 1/2}, {x, 0, 4 Pi},  
 Filling -> {2 -> {0, {Automatic, None}}}]

enter image description here

Alternatively,

Plot[{Cos[x], Sin[x] + 1/2}, {x, 0, 4 Pi}, 
 Filling -> {2 -> {Axis, {Automatic, None}}}]
same picture

You can also use Filling + FillingStyle

Plot[{Cos[x], Sin[x] + 1/2}, {x, 0, 4 Pi},  
  Filling -> {2 -> 0},
  FillingStyle -> {Opacity[.3, Red], None}]

enter image description here

Note: For some reason, FillingStyle -> {Automatic, None} does not work.

kglr
  • 394,356
  • 18
  • 477
  • 896