I would like to replicate this plot:
From A parametric model for dark energy.
But how can I add the lines and the grids to the various sections?
I would like to replicate this plot:
From A parametric model for dark energy.
But how can I add the lines and the grids to the various sections?
inequalities = {y >= -x,
y < -x && x >= -.45,
5 + 5 x <= y <= -x - 1.1,
Min[5 + 5 x, -x] >= y >= -x - 1.1 && x <= -.45};
regions = ImplicitRegion[{#}, {{x, -3/2, 0}, {y, -2, 2}}] & /@ inequalities;
labels = {"forbidden", "decelerated", "phantom", "quintessence"};
fillings = {PatternFilling["Diamond", ImageScaled[1/50]],
HatchFilling[-Pi/4],
HatchFilling[Pi/2],
HatchFilling[]};
legends = SwatchLegend[fillings /. ImageScaled[_] -> ImageScaled[1/4],
inequalities, LegendMarkerSize -> 30]
epilog = MapThread[Text[Style[Framed[#, Background -> White, FrameStyle -> White],
16], RegionCentroid @ #2, Center] &, {labels, regions}];
RegionPlot[Evaluate @ regions,
PlotRange -> {{-3/2, 0}, {-2, 2}},
ImageSize -> Large,
BoundaryStyle -> Directive[Thick, Black],
Epilog -> epilog,
PlotLegends -> legends,
PlotStyle -> Thread[Directive[Black, fillings]]]
For versions before 12.1, we can use MeshFunctions and Mesh to get a similar look:
inequalities = {y >= -x,
y < -x && x >= -.45,
5 + 5 x <= y <= -x - 1.1,
Min[5 + 5 x, -x] >= y >= -x - 1.1 && x <= -.45};
regions = ImplicitRegion[{#}, {{x, -3/2, 0}, {y, -2, 2}}] & /@ inequalities;
labels = {"forbidden", "decelerated", "phantom", "quintessence"};
meshfunctions = {{4 # + 3/2 #2 &, 3/2 #2 - 4 # &},
{# + #2 &},
{# &},
{# - #2 &}};
meshes = {{80, 100}, 60, 30, 50};
epilog = MapThread[Text[Style[Framed[#, Background -> White, FrameStyle -> White], 14],
RegionCentroid @ #2, Center] &,
{labels, regions}];
rp = Show[MapThread[
RegionPlot[#,
PlotRange -> {{-3/2, 0}, {-2, 2}},
MeshFunctions -> #2,
Mesh -> #3,
MeshStyle -> Darker@Gray,
ImageSize -> 400,
BoundaryStyle -> Directive[Thick, Black],
PlotStyle -> None] &,
{regions, meshfunctions, meshes}],
Epilog -> epilog]
Adding a hatch-filled legend requires additional work: We can create RegionPlots with desired hatching patterns using MeshFunctions and Mesh as above and use them as legend markers making use of the (undocumented) option "LegendItem" for LineLegend:
hatchLegend = RegionPlot[True, {x, 0, 1}, {y, 0, 1},
Frame -> True,
FrameTicks -> False,
PlotRange -> {{0, 1}, {0, 1}},
ImagePadding -> 1,
PlotRangeClipping -> False,
MeshFunctions -> #,
Mesh -> #2,
MeshStyle -> Directive[AbsoluteThickness[1], #3],
ImageSize -> 30,
FrameStyle -> Directive[AbsoluteThickness[1], Black],
PlotStyle -> None] &;
legenditems = MapThread[hatchLegend,
{ReplacePart[{1} -> {# + #2 &, #2 - # &}] @ meshfunctions,
{10, 10, 7, 10},
ConstantArray[Darker @ Gray, 4]}];
legend = LineLegend[{White, Gray, Gray, Gray},
inequalities,
"LegendItem" -> legenditems,
LegendMarkerSize -> {20, 20}];
Legended[rp, legend]