8
$\begingroup$

I have two curves plotted on the same plot. To the left of a given domain value, I want to fill between curve 1 and the x-axis; to right of that value, I want to fill between the two curves.

enter image description here

$\endgroup$
4
  • 3
    $\begingroup$ What are people supposed to do with your figure? $\endgroup$ Commented Nov 18, 2019 at 16:05
  • $\begingroup$ @Nina: Did you see these posts mathematica.stackexchange.com/questions/33126/…, mathematica.stackexchange.com/questions/20721/…? $\endgroup$
    – Moo
    Commented Nov 18, 2019 at 16:31
  • $\begingroup$ Thank you for the link, but that could be applied only there is an intersection in between. $\endgroup$
    – Nina
    Commented Nov 18, 2019 at 17:09
  • $\begingroup$ @Nina To help you, people will need the data or the analytical expressions that generated those curves. We can't help you otherwise. $\endgroup$
    – MarcoB
    Commented Nov 18, 2019 at 17:34

2 Answers 2

12
$\begingroup$

Here's an adaptation of m_goldberg's answer that uses a single plot for his example:

Plot[
    {
    c2[x],
    ConditionalExpression[c1[x], x<.7],
    ConditionalExpression[c1[x], x>.7]
    },
    {x, 0,1},
    PlotStyle->{Red, Blue, Blue},
    Filling->{2->{Axis, LightBlue}, 1->{{3}, LightBlue}}
]

enter image description here

$\endgroup$
8
$\begingroup$

Here is one way to do what you are asking for.

Functions and given point

c2[x_] := x^(1/2)
c1[x_] := x^3
x0 = .7;

Now we make three plots ...

p1 = Plot[{c1[x], c2[x]}, {x, 0, 1}, Epilog -> {Blue, Dashed, Line[{{x0, 0}, {x0, 1}}]}]

p1

p2 = Plot[c1[x], {x, 0, x0}, Filling -> Bottom]

p2

p3 = Plot[{c1[x], c2[x]}, {x, x0, 1}, Filling -> {1 -> {2}}]

p3

... and combine them with Show.

Show[p1, p2, p3]

all

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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