I want to fill the region between two straight lines without displaying the region boundaries. How can it be done?
ContourPlot[{x == 2, x == 4}, {x, -2, 8}, {y, -2, 6}]
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 communityUse BoundaryStyle -> None
as shown in the documentation of RegionPlot
:
RegionPlot[2 <= x <= 4, {x, -2, 8}, {y, -2, 6}, BoundaryStyle -> None]
is this what you mean?
p1 = ContourPlot[{x == 2, x == 4}, {x, -2, 8}, {y, -2, 6}];
r = ImplicitRegion[2 < x < 4 && -2 < y < 6, {x, y}];
p2 = RegionPlot[r];
Show[p1, p2]
Update
In this case, just plot the region directly. No need for ContourPlot
at all to be there.
r = ImplicitRegion[2 < x < 4 && -2 < y < 6, {x, y}];
RegionPlot[r, BoundaryStyle -> None,
PlotRange -> {{-2, 8}, Automatic}]
c := RandomInteger[{-100, 100}];
RegionPlot[RegionIntersection[
HalfPlane[{{2, c}, {2, c}}, {1, 0}]
, HalfPlane[{{4, c}, {4, c}}, {-1, 0}]
]
, Frame -> True
, BoundaryStyle -> None
, PlotRange -> { {-2, 8}, {-2, 6}}
]