I have the following straight line:
y[x_] = 4 x - 1;
Plot[y[x], {x, 0, 1}, PlotRange -> {{0, 1}, {0, 2}}]
I want to highlight the two regions separated by the straight line, such that they look nice and distinct.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityy[x_] := 4 x - 1;
Plot[{y[x], y[x]}, {x, 0, 1}, PlotStyle -> Blue,
PlotRange -> {{0, 1}, {0, 2}},
Filling -> {1 -> {Top, LightYellow}, 2 -> {Bottom, LightBlue}}]
One can also use InfiniteLine[]
and HalfPlane[]
for this:
Graphics[{{LightYellow, HalfPlane[{0, -1}, {1, 4}, Cross[{1, 4}]]},
{LightBlue, HalfPlane[{0, -1}, {1, 4}, -Cross[{1, 4}]]},
{Blue, InfiniteLine[{0, -1}, {1, 4}]}},
AspectRatio -> 1/GoldenRatio, Axes -> True, PlotRange -> {{0, 1}, {0, 2}}]