I want to this:
from this picture ,can find that "red" in front of "blue"
My code:
Clear["Global`*"];
(*=== data ===*)
ptdata = {{0, 6}, {0.6, 4}, {1.4, 2.8}};
(*=== define function ===*)
interfun1[x_] := InterpolatingPolynomial[ptdata, x];
interfun2[x_] := interfun1@x - 2;
(*=== plot ===*)
Plot[
{
If[x < 1.2, interfun1@x],
If[x >= 1.2, interfun1@x],
If[x < 1, interfun2@x],
If[x >= 1, interfun2@x]
},
{x, 0, Pi/2},
Filling -> {
2 -> {Top, Directive[Opacity@1, Red]},
4 -> {Top, Directive[[email protected], Blue]}
}
]
get this
I use mathematica own tools, I found that the red was covered with blue
By checking the forums, this post might be useful, but I can't make sense of it
How can I deal with this problem?
Plot[{If[x < 1, interfun2@x], If[x >= 1, interfun2@x], If[x < 1.2, interfun1@x], If[x >= 1.2, interfun1@x]}, {x, 0, Pi/2}, Filling -> {4 -> {Top, Directive[Opacity@1, Red]}, 2 -> {Top, Directive[[email protected], Blue]}}]
$\endgroup$