# How can I fill regions from range of x and y?

I have two lists below and each element in rangeX with the corresponding element in rangeY form a region/regions (or a line/lines in some case).

rangeX = {(x >= 3 || x <= -4) && -5 <= x <= 5, -1 <= x <= 0, -5 <=
x <= 0};
rangeY = {1 <= y <= 5, y == 1, 1 <= y <= 5};


For example, the first element of each list (x >= 3 || x <= -4) && -5 <= x <= 5 and 1 <= y <= 5 would form a region as follows:
The marking is just to illustrate (it could be cross like that or colors or anything else).
The plot range is limited in a rectangle -5 < x < 5 and  0 < y < 5 as in the image.

This is just my draft code to generate the region.

Plot[6, {x, -5, 5}, PlotRange -> {{-5, 5}, {0, 5}},
GridLines -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5] },
Ticks -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
TicksStyle -> Directive[Red, 10, Bold]]


How can I fill the regions like this?
I would like to do something like Manipulate with button1, button2, button3 for regions formed by first, second, third elements of each list and button4 for showing all three in one plot.
I'm still stuck at how to fill the regions from the ranges of x, y.

impregs = ImplicitRegion[#, {{x, -5, 5}, {y, 0, 6}}] & /@ Thread[{rangeX, rangeY}];

RegionPlot[#, PlotStyle -> None, BaseStyle -> Thin,
MeshStyle -> #2, MeshFunctions -> #3, Mesh -> #4, BoundaryStyle -> #5] &,
{impregs, {Red, Green, Blue}, {# + 2 #2 &, #2 &, # - 2 #2 &}, {70, 50, 50}, {None,
Directive[CapForm["Round"], AbsoluteThickness[5], Opacity[1],  Green], None}}];

Show[plots,
GridLines -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
PlotRange -> {{-5, 5}, {0, 5}},
Ticks -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]}]


Manipulate[Show[If[indices === {}, Graphics[{}], plots[[indices]]],
GridLines -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
AspectRatio -> 1, PlotRange -> {{-5, 5}, {0, 5}},
Ticks -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]}],
{ {indices, {1}, "regions"},
(Style[("region "<>ToString[#]), {Red, Green, Blue}[[#]], 16, Bold]& /@ Range[3])],
TogglerBar, Background -> GrayLevel[.6]}]


Show[MapThread[RegionPlot[#, PlotStyle -> #2, BaseStyle -> Thin, BoundaryStyle -> #3,
PlotLegends -> SwatchLegend[{#[[1]]}, LegendMarkerSize -> {40, 40}]] &,
{impregs,
{Directive[Red, HatchFilling[]], Directive[Green, HatchFilling[0]],
Directive[Blue, HatchFilling[-Pi/4]]},
{None,  Directive[CapForm["Round"], AbsoluteThickness[5],
Opacity[1], Green], None}}],
GridLines -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
PlotRange -> {{-5, 5}, {0, 5}},
Ticks -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]}]


• very nice images!
– hana
Mar 29, 2022 at 20:11

You can get started with something like this:

RegionPlot[
ImplicitRegion[(x >= 3 || x <= -4) && -5 <= x <= 5 && 1 <= y <= 5, {x, y}]]

• You can get the combinations of your conditions with something like this conditions = Flatten@Outer[And, rangeX, rangeY]. You can follow that up by mapping ImplicitRegion over the conditions and finally RegionPlot-ting those. Mar 29, 2022 at 18:02
• Having said all of this, Regions can be a bit finicky (and slow). So, depending on what level of accuracy you want and what kind of presentation you want, there may be better approaches. Mar 29, 2022 at 18:04
• Yeah, knowing this function is helpful.
– hana
Mar 29, 2022 at 20:12

Edit: more faithful image

lines[xx_, yy_] := Graphics[
{xx, Table[
InfiniteLine[{0, i}, AngleVector[yy]], {i, -2, 2, .05}]},
PlotRange -> 1/2];
RegionPlot[
ImplicitRegion[rangeX[[1]], {x, y}],
PlotRange -> {{-5, 5}, {0, 5}},
GridLines -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
PlotStyle -> {Texture[lines[Black, -\[Pi]/4]]},
BoundaryStyle -> None,
Axes -> True,
AxesStyle -> Thick,
Ticks -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
TicksStyle -> Directive[Red, 10, Bold],
Frame -> False,
ImageSize -> Large]


lines[xx_, yy_] := Graphics[
{xx, Table[
InfiniteLine[{0, i}, AngleVector[yy]], {i, -2, 2, .05}]},
PlotRange -> 1/2];
RegionPlot[
ImplicitRegion[rangeX[[1]], {x, y}],
PlotRange -> {{-5, 5}, {0, 5}},
GridLines -> {Range[-5, 5, 0.5], Range[-5, 5, 0.5]},
PlotStyle -> {Texture[lines[Black, -\[Pi]/4]]},
BoundaryStyle -> None,
FrameTicks -> {{None, None}, {Range[-5, 5, 0.5], None}},
FrameTicksStyle -> {{None, None}, {Directive[Red, 10, Bold], None}}]


• Thanks, indeed similar but better drawing!
– hana
Mar 29, 2022 at 20:14
• Glad I was able to help. Check also what @kglr did. Pretty impressive!!!
– bmf
Mar 29, 2022 at 20:14