6
$\begingroup$

I am plotting to functions that look like this:

Example

I have used Filling -> Axis inside a plot and it produces the above example. My question is if I can more control over the coloring.

Specifically, I would like to set the area below the two curves to a color while setting all the other ares to white (no coloring). Notice that this is different from coloring the intersection or the area between the two curves. Any suggestions?

$\endgroup$
  • 2
    $\begingroup$ It always (?) helps us to help you if you post your unsatisfactory code so we can cut'n'paste it and tweak it. I'm far too lazy to experiment to answer your question ab initio. I suspect other people around here are too busy but either way, show us yer code. $\endgroup$ – High Performance Mark Jun 8 '20 at 10:41
  • $\begingroup$ Possible duplicate: (9684) $\endgroup$ – Mr.Wizard Jun 9 '20 at 21:09
8
$\begingroup$

Perhaps you're looking for something like this:

Plot[{
  ConditionalExpression[x^2, x < 1],
  ConditionalExpression[x^2, x > 1],
  ConditionalExpression[2 + 2 x^2, x < 1]
  },
 {x, 0, 2},
 Filling -> {1 -> Bottom}
 ]

Output

$\endgroup$
4
$\begingroup$
threshold = 1.;

Plot[{x^2, x^2/6, ConditionalExpression[0, x <= threshold]}, {x, 0, 2}, 
 PlotStyle -> {Automatic, Orange, None}, 
 Filling -> {2 -> {{3}, {None, LightOrange}}},
 PlotRange -> {0, 1}]

enter image description here

and

Plot[{x^2, x^2/6, Boole[x > threshold ]}, {x, 0, 2},
 Exclusions -> {{threshold }},
 PlotStyle -> {Automatic, Orange, None}, 
 Filling -> {2 -> {{3}, {None,LightOrange}}},
 PlotRange -> {0, 1}]

enter image description here

$\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.