2
$\begingroup$

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.

$\endgroup$

1 Answer 1

4
$\begingroup$
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

$\endgroup$
1
  • 2
    $\begingroup$ Appreciate the prompt response@kglr. Also one can add PlotStyle -> Transparent , to the module for superimposing on other colored plots. $\endgroup$
    – BumbaS
    Commented Feb 28, 2021 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.