14
$\begingroup$

How can I make a hatching filling of the plot?

Like this:

hatching filling plot

I used another plot with shifting to make the filled area above:

plot := ListLinePlot[
  Table[{x1[w], x2[w]}, {w, 1.5, 5, .005}],     
  Filling -> Top,
  FillingStyle -> White
  ]

fill := ListLinePlot[
  Table[{x1[w] - 0.01, x2[w] - 0.02}, {w, 1.5, 5, .005}],
  Filling -> Top,
  FillingStyle -> LightGray,
  PlotStyle -> LightGray
  ]

Show[fill, plot]

plot

How can I make hatching filling of the filled-plot?

$\endgroup$

2 Answers 2

19
$\begingroup$

Something like this?

    RegionPlot[y < 1/x && y + 0.3 > 1/(x + 0.3) , {x, 0, 3}, {y, 0, 4}, 
  AxesOrigin -> {0, 0}, Frame -> False, Axes -> Automatic, Mesh -> 20,
   MeshFunctions -> {#1 - #2 &}, BoundaryStyle -> None]~Show~
 Plot[1/x, {x, 0, 3}]

Mathematica graphics

You can add PlotStyle -> Transparent to the RegionPlot if you don't want the blue filling, and xkcdify it

enter image description here

$\endgroup$
8
  • $\begingroup$ Beware! The anti-xkcdification patrol is here! mathematica.stackexchange.com/a/13359/193 $\endgroup$ Oct 24, 2012 at 22:12
  • 1
    $\begingroup$ @belisarius, oh, but it very much fits the context. I'll defend it as if it was Howgartz against any evil wizard $\endgroup$
    – Rojo
    Oct 25, 2012 at 1:39
  • 5
    $\begingroup$ You may always sweeten the answer by throwing in some infix notation. $\endgroup$
    – Yves Klett
    Oct 25, 2012 at 12:33
  • 1
    $\begingroup$ @shed, if you want to plot the borders of that region, I'd go with ContourPlot[x1[w] == x2[g], {w, 1.5, 5}, {g, 1.5, 5}] $\endgroup$
    – Rojo
    Oct 26, 2012 at 13:55
  • 1
    $\begingroup$ @shed you probably should accept this one, or you are still hoping for something different? $\endgroup$
    – Rojo
    Dec 9, 2013 at 22:13
1
$\begingroup$

Using Region functionality:

Clear["Global`*"];

Show[Plot[1/x
  , {x, 0, 1}
  , PlotStyle -> Black
  , PlotRange -> {0, 7}
  , RegionFunction -> Function[{x, y}, x > 0]
  , AxesLabel -> TraditionalForm /@ {x[t], y[t]}
  , LabelStyle -> Directive[Black, Medium]
  ]
 , RegionPlot[y < 1/x && y > 0.8/x - 0.2
  , {x, 0, 1}, {y, 0, 7}
  , BoundaryStyle -> None
  , PlotStyle -> {Black, HatchFilling[1, 0.1, 12]}
  ]
 ]

enter image description here

$\endgroup$

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.