2
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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

$\endgroup$
1
$\begingroup$

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

$\endgroup$

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.