2

Need to fill the region between two data sets with colored hatched (\ || //) lines in LogLog scale. I use Mathematica 11.1. Apparently HatchFilling nor PatternFilling are available.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
BumbaS
  • 19
  • 1

1 Answers1

4
ClearAll[addHatchFilling]
addHatchFilling[meshfunctions_: Automatic, meshstyle_: Automatic, 
   mesh_: Automatic, meshshading_: Automatic] := 
  ReplaceAll[p_Polygon :> {p, 
    First[RegionPlot[DiscretizeRegion[p], 
     MeshFunctions -> (meshfunctions /. Automatic -> {# + #2 &}), 
     MeshStyle -> (meshstyle /. Automatic -> Directive[Thick, Opacity[1], White]),
     Mesh -> (mesh /. Automatic -> 40), 
     MeshShading -> (meshshading /. Automatic -> None)]]}] @* Normal;

Examples:

{list1, list2} = {Transpose[{Range @ 20, Range @ 20}], 
   Transpose[{Range @ 20, Sqrt @ Range @ 20}]};

llp = ListLogLogPlot[{list1, list2}, Joined -> True, Filling -> {1 -> {2}}, ImageSize -> 400];

Row[{llp, addHatchFilling[] @ llp}, Spacer[10]]

enter image description here

Row[{addHatchFilling[{# &}, 
    Directive[Opacity[1], CapForm["Butt"], AbsoluteThickness[5], Orange], 30]@llp, 
  addHatchFilling[{# &, #2 &}, Automatic, {20, 20}] @ llp}, Spacer[10]]

enter image description here

Row[{addHatchFilling[{#2 &}, 
    Directive[Opacity[1], CapForm["Butt"], AbsoluteThickness[2], Red],
    20, 
    {Opacity[1, Cyan], Opacity[1, Yellow]}] @ llp, 
  addHatchFilling[{# + #2 &, #2 - # &}, 
    Automatic, 
    {20, 10}, 
    {{Opacity[1, Red], None}, {None, Opacity[1, Yellow]}}] @ llp}, 
  Spacer[10]]

enter image description here

$Version
 "11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)"

See also: Generating hatched filling using Region functionality

kglr
  • 394,356
  • 18
  • 477
  • 896
  • 2
    Appreciate the prompt response@kglr. Also one can add PlotStyle -> Transparent , to the module for superimposing on other colored plots. – BumbaS Feb 28 '21 at 08:09