# How to fill a region with lines

How to fill a region with lines:

Plot[{t + 1, t}, {t, 0, 4}, PlotRange -> {0, 4},Filling -> {1 -> {2}}]


I want to change the filling style to vertical lines, as shown in the right figure below. How should I change the code? • In addition to the answe below, you may want to search this site for "hatched" or "hashed" filling. There have been a few examples, the best of which seem to rely on using a RegionPlot of the region and mesh lines. Mar 21, 2016 at 4:11
• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Mar 21, 2016 at 8:48
• Strongly related: "Generating hatched filling using Region functionality." Mar 21, 2016 at 8:57

funs = {t + 1, t};

Show[{Plot[funs, {t, 0, 4}, PlotRange -> {0, 4}],
RegionPlot[funs[] < y < funs[], {t, 0, 10}, {y, 0, 6},
Mesh -> 60, MeshFunctions -> {#1 &}, BoundaryStyle -> None,
MeshStyle -> {Gray, Thickness[.001]}, PlotStyle -> Transparent]}] Just for fun,to show the flexibility of this method:

Show[{Plot[funs, {t, 0, 4}, PlotRange -> {0, 4}],
RegionPlot[funs[] < y < funs[], {t, 0, 10}, {y, 0, 6},
Mesh -> 60, MeshFunctions -> {Sin[#1] Sin[#2] &},
BoundaryStyle -> None, MeshStyle -> {Gray, Thickness[.001]},
MeshShading -> {Red, Green, None, Yellow},
PlotStyle -> Transparent]}] you could use GridLines also

Plot[{t + 1, t}, {t, 0, 4}, PlotRange -> {0, 4},
GridLines -> {Range[0, 4, .2], None},
Filling -> {1 -> {Top, White}, 2 -> {Bottom, White}}] I guess the simplest way is:

Show[
ListPlot[{
Table[i*2 + 1, {i, -1, 3, 0.1}],
Table[i*2 + 3, {i, -1, 3, 0.1}]}, Joined -> True],
ListPlot[{
Table[i*2 + 1, {i, -1, 3, 0.1}],
Table[i*2 + 3, {i, -1, 3, 0.1}]
}, Joined -> False, Filling -> {1 -> {2}},
PlotStyle -> PointSize[0.001]]
]


The point-based representation allows to have a discrete line-based filling. A modification of Rom38's.

Show[
Plot[{t + 1, t}, {t, 0, 4}, PlotRange -> {0, 4}],
ListLinePlot[Table[{{i, i + 1}, {i, i}}, {i, 0, 4, 0.2}], PlotStyle -> {{Gray, Thin}}]
] Another option with Epilog:

Plot[{t + 1, t}, {t, 0, 4}, PlotRange -> {0, 4},
Epilog -> Table[Line @ {{i, i}, {i, i + 1}}, {i, 0, 4, 0.2}]] Using Epilog

Plot[{t + 1, t}, {t, 0, 4},
PlotRange -> {0, 4},
Epilog -> Line /@ (Thread@{#, {# + 1, #}} & /@ Range[0, 4, 0.2])] Here's yet another way to get what you are going for, by using ContourPlot

ContourPlot[#, {x, 0, 4}, {y, 0, 4}, ContourShading -> False,
Contours -> 20] & /@ {{x == y,
x + 1 == y},
Piecewise[{{x, x < y < x + 1}}, Indeterminate]} // Show 