# Problem with Filling Style

I got two functions and want to plot them using different plotstyle so they can be shown distinctively after printing with black ink. I also need to fill the region between them and label the two regions. I prefer to use Dot or Hatched Filling but don't know how to do it. Here is my code:

ifun = Interpolation[{{14.800000000000011,
0.3001}, {15.750000000000025, 0.2501}, {16.650000000000038,
0.2001}, {17.60000000000005, 0.1501}, {19.300000000000075,
0.10010000000000001}, {20.35000000000009,
0.1501}, {20.700000000000095, 0.2001}, {20.9500000000001,
0.2501}, {21.1000000000001, 0.3001}, {21.250000000000103,
0.35009999999999997}, {21.350000000000104,
0.40009999999999996}, {21.450000000000106,
0.45009999999999994}, {21.550000000000107,
0.5001}, {21.65000000000011, 0.5501}, {21.70000000000011,
0.6001000000000001}, {21.75000000000011,
0.6501000000000001}, {21.80000000000011,
0.7001000000000002}, {21.900000000000112,
0.7501000000000002}, {21.950000000000113, 0.8001000000000003}}]
f[x_] := 0.3001 /; 14 < x < 14.8
f[x_] := ifun[x] /; 14.8 < x < 21.95
f[x_] := 0.9001 /; 21.95 < x < 24.95
g[x_] := 0.9001 /; 14 < x < 21.95
Plot[{g[X], f[x]}, {x, 14, 24.95},
Filling -> {1 -> {2}, 2 -> Axis}, PlotLabel -> Profit,
AxesLabel -> {"c", "Phi"},
PlotLegends ->
SwatchLegend[{"TS", "ST"}, LegendLabel -> "Label",
LegendFunction -> (Framed[#, Background -> White] &)]]

Thank you very much!

• Check the documentation for FillingStyle > Scope > Filling Style. You'll see that you can specify graphics directives in the filling specification, e.g. Filling -> {1 -> {{2}, Directive[Yellow]}, 2 -> {Axis, Directive[Green]}} (but, of course, with your own directives instead of Yellow and Green). Also see the PlotStyle option for changing the style of the plotted curves themselves! May 9, 2020 at 3:35
• (Also, by the way, I think you've got a typo in your Plot function here: g[X]] should, it seems, be g[x]) May 9, 2020 at 3:35
• Also check out Show, which lets you overlay graphics, and could let you overlay text graphics onto the region areas, perhaps. May 9, 2020 at 3:36
• Also! Check out HatchFilling[...] and PatternFilling[...] to use in place of Directive[Yellow] and Directive[Green]! May 9, 2020 at 3:41
• Dear thorimur, thank you very much for answering my questions. But I have tried what you have suggested, it seems they do not work. It is easy to get some colorful regions when using Mathematica. But I want to make my Graph easy to see when printed with black ink. May 10, 2020 at 3:06

## 1 Answer

Plot[{g[x], f[x]}, {x, 14, 24.95},
PlotTheme -> {"Monochrome", "ThickLines"},
Filling -> {1 -> {{2}, HatchFilling[45 Degree]},
2 -> {Axis, HatchFilling[-45 Degree]}},
PlotLabel -> "Profit",
AxesLabel -> {"c", "Phi"},
PlotLegends -> SwatchLegend[{HatchFilling[45 Degree], HatchFilling[-45 Degree]},
{"TS", "ST"}, LegendLabel -> "Label",
LegendFunction -> (Framed[#, Background -> White] &),
LegendMarkerSize -> 20]]

• I'll just add on to this that in order to get dots, for example, one can use PatternFilling["HalftoneGrid",ImageScaled[1/20]]. PatternFilling also admits several other black and white patterns. May 11, 2020 at 20:58
• Thank you so much! May 25, 2020 at 9:14
• But I have tried many times, it did not work. It said "HatchFilling is not a Graphics primitive or directive". May 25, 2020 at 9:44