For "RegionPlot", how to fill lines, points, or grids in different areas?
I have tried "Mesh", but it fills all region in same mesh.
I want to get the result just like this picture,
Thank you!
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityFor "RegionPlot", how to fill lines, points, or grids in different areas?
I have tried "Mesh", but it fills all region in same mesh.
I want to get the result just like this picture,
Thank you!
regions = {(x - 2)^2 < (y - 2)^3 + 1, (x - 2)^2 > (y - 2)^3 + 1 &&
y > x - 3, y < Min[2, x - 3], x - 3 > y > 2 && x > 5};
You can specify PlotStyle
using PatternFiling
:
plotstyles = MapThread[PatternFilling[{#, #2}, ImageScaled[#3]] &,
{{"Diamond", "HalftoneGrid", "Grid", "Chevron"},
ColorData[97] /@ Range[4], {1/40, 1/40, 1/40, 1/50}}];
RegionPlot[regions, {x, 0, 10}, {y, 0, 5},
AspectRatio -> Automatic, ImageSize -> 700,
BoundaryStyle -> Thick,
PlotLegends -> SwatchLegend["Expressions", LegendMarkerSize -> 40],
PlotStyle -> plotstyles] /.
s_SwatchLegend :> (s /. ImageScaled[a_] :> ImageScaled[10 a])
Replace the last entry in plotstyles
with HatchFilling
:
plotstyles[[4]] = Directive[ColorData[97] @ 4, HatchFilling["Horizontal"]];
to get
If it is good enough for you, you may fill with colors, using the option Filling
:
Plot[{Sin[2 x], 1 + x^2, 2 + x}, {x, 0, 1}, Filling -> Automatic]