# HatchFilling in Mathemathica fills the entire are under curve

The Hatchfilling command is failing for me, i want to fill the area under the curve with vertical lines. If any suggestions plz do share. Thankyou.

filling1 =
ParametricPlot[{x, y}, {x, 0, 2 \[Pi]}, {y, 0, Sin[x]},
MeshFunctions -> {1*#1 + 0*#2 &}, Mesh -> 80, MeshStyle -> Red,
PlotStyle -> None, PlotPoints -> 100, BoundaryStyle -> None];
filling2 =
ParametricPlot[{x, y}, {x, 0, 2 \[Pi]}, {y, 0, Cos[x]},
MeshFunctions -> {1*#1 + 0*#2 &}, Mesh -> 80, MeshStyle -> Blue,
PlotStyle -> None, PlotPoints -> 100, BoundaryStyle -> None];
Show[Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi},
PlotStyle -> {Red, Blue}], filling1, filling2]


Maybe work in your Mathematica version.

plot = Plot[Sin[x], {x, 0, 2 Pi}];
filling =
ParametricPlot[{x, y}, {x, 0, 2 π}, {y, 0, Sin[x]},
MeshFunctions -> {1*#1 + 0*#2 &}, Mesh -> 80, PlotStyle -> None,
PlotPoints -> 100, BoundaryStyle -> None];
Show[plot, filling]


• Worked. Thankyou! Jun 12, 2021 at 8:55
• If we want to add another function let's say cos[x], Can this code be transformed for it. Tried but Alas! Jun 12, 2021 at 9:16
• @SyedShahmirKazmi See the updated. Jun 12, 2021 at 14:43

It seems HatchFilling is not available in your Mathematica. Which version are you using? This functionality was introduced in version 12.1.

You can get what you want using

Plot[Sin[x], {x, 0, 2 Pi}, Filling -> Axis,
FillingStyle -> HatchFilling[Pi/2]]

• ok understood. Mine version is 11.2 Jun 12, 2021 at 8:54