# Filling a region between two straight lines

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}]

Use BoundaryStyle -> None as shown in the documentation of RegionPlot:

RegionPlot[2 <= x <= 4, {x, -2, 8}, {y, -2, 6}, BoundaryStyle -> None]


• Thanks, @Roman. It's working. Oct 3, 2022 at 8:53
• Just saw your answer after I updated. Oct 3, 2022 at 8:59

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}]


• Thanks, @Nasser for your answer. You are almost close. I just don't want the border lines surrounding the region. Oct 3, 2022 at 8:50
• @SahabubJahedi fyi, updated Oct 3, 2022 at 8:59
• Thanks, @Nasser, it's working. Oct 3, 2022 at 12:05
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}}
]