# Regionplot with legend marker

I only have one region plot and still want to get the legend (both marker and label). I tried the following, but why the legend market does not show up?

RegionPlot[x^2 < y^3 + 1 && y^2 < x^3 + 1, {x, -2, 5}, {y, -2, 5}, PlotLegends -> Placed["MyLegend", {0.15, 0.08}]] Edit: Thanks @kglr for pointing out that {"MyLegend"} works in the original simple example. This helped me realize that what I want to achieve is slightly different. Since I use mesh to highlight the region, I was trying to get the legend for the mesh. Please see the code below:

RegionPlot[x^2 < y^3 + 1 && y^2 < x^3 + 1, {x, -2, 5}, {y, -2, 5}, MeshFunctions -> {#1 - #2 &}, Mesh -> 12, MeshStyle -> {Hue[0.75], Opacity[0.3]}, PlotStyle -> None, BoundaryStyle -> None, PlotLegends -> Placed[{"MyLegend"}, {0.15, 0.15}]] • try PlotLegends -> Placed[{"MyLegend"}, {0.15, 0.08}]?
– kglr
May 3, 2021 at 3:36
• RegionPlot[x^2 < y^3 + 1 && y^2 < x^3 + 1, {x, -2, 5}, {y, -2, 5}, BoundaryStyle -> None, PlotStyle -> HatchFilling[45, 1, 3], PlotLegends -> Placed["AllExpressions", {0.25, 0.8}]] May 3, 2021 at 5:23

If the only reason for using Mesh is to get a hatch filling for the region, you can use HatchFilling:

RegionPlot[x^2 < y^3 + 1 && y^2 < x^3 + 1, {x, -2, 5}, {y, -2, 5},
PlotStyle -> Directive[Hue @ .75, Opacity @ .3, HatchFilling[Pi/4, 0, 10]],
BoundaryStyle -> None,
PlotLegends -> Placed[SwatchLegend[{"MyLegend"}, LegendMarkerSize -> 30], {0.2, 0.1}]] If you have to use Mesh + MeshStyle you can do

legendmarker = RegionPlot[True, {x, 0, 1}, {y, 0, 1},
Frame -> False,
MeshFunctions -> {#1 - #2 &}, Mesh -> 7,
MeshStyle -> Directive[Hue[0.75], Opacity[0.3]],
PlotStyle -> None, BoundaryStyle -> None];

RegionPlot[x^2 < y^3 + 1 && y^2 < x^3 + 1, {x, -2, 5}, {y, -2, 5},
MeshFunctions -> {#1 - #2 &}, Mesh -> 12,
MeshStyle -> {Hue[0.75], Opacity[0.3]}, PlotStyle -> None,
BoundaryStyle -> None,
PlotLegends -> Placed[SwatchLegend[ {"MyLegend"}, LegendMarkerSize -> {20, 20},
LegendMarkers -> {legendmarker}], {0.2, 0.075}]] • The use of HatchFilling looks good. However, this command seems not recognized by my Mathematica 11.0. The color of this command is blue when I typed it, and the graph does not have parallel lines. So I guess this a version issue May 3, 2021 at 18:09
• I upgraded my software to 12.2 - now it works. Thanks! May 3, 2021 at 19:01
RegionPlot[x^2 < y^3 + 1 && y^2 < x^3 + 1,
{x, -2, 5}, {y, -2, 5},
PlotLegends ->
Placed[SwatchLegend[{x^2 < y^3 + 1 && y^2 < x^3 + 1}], {0.3, .07}]] 