Perhaps a "quick" appoach (in addition to looking at hyperlink of @rm-rf):

```
msp[f_, {xmin_, xmax_}, {ymin_, ymax_}, mfun_, mnum_, swatchsize_,
opts : OptionsPattern[]] := Module[{pm, swl},
pm = RegionPlot[x < 1, {x, 0, 1}, {y, 0, 1}, MeshFunctions -> mfun,
Mesh -> IntegerPart@(mnum/(swatchsize/10)), Frame -> False,
PlotRange -> {{0, 1}, {0, 1}},
Evaluate@FilterRules[{opts}, Options[RegionPlot]],
ImageSize -> swatchsize];
swl = SwatchLegend["Expressions", LegendMarkers -> pm,
LegendMarkerSize -> swatchsize];
RegionPlot[f, {x, xmin, xmax}, {y, ymin, ymax},
MeshFunctions -> mfun, Mesh -> mnum,
Evaluate@FilterRules[{opts}, Options[RegionPlot]],
PlotLegends -> swl]]
```

Some examples:

```
msp[x^2 + y^3 < 2, {-2, 2}, {-2, 2}, {#1 &, #2 &}, 50, 50]
```

```
msp[x^2 + y^3 < 2, {-2, 2}, {-2, 2}, {#1 + #2 &, #1 - #2 &}, 50, 50]
```

```
msp[x^2 + y^3 < 2, {-2, 2}, {-2, 2}, {#1 &, #2 &}, 50, 50,
PlotStyle -> Yellow, BoundaryStyle -> {Thick, Purple}]
```

**UPDATE**

```
mspmod[f_, {xmin_, xmax_}, {ymin_, ymax_}, mfun_, mnum_, swatchsize_,
col_, opts : OptionsPattern[]] :=
Module[{pm, swl},
pm = RegionPlot[x < 1, {x, 0, 1}, {y, 0, 1}, MeshFunctions -> mfun,
Mesh -> IntegerPart@(mnum/(swatchsize/10)), Frame -> False,
PlotRange -> {{0, 1}, {0, 1}}, PlotStyle -> #,
Evaluate@FilterRules[{opts}, Options[RegionPlot]],
ImageSize -> swatchsize] & /@ col;
swl = SwatchLegend["Expressions", LegendMarkers -> pm,
LegendMarkerSize -> swatchsize];
RegionPlot[f, {x, xmin, xmax}, {y, ymin, ymax},
MeshFunctions -> mfun, Mesh -> mnum, PlotStyle -> col,
Evaluate@FilterRules[{opts}, Options[RegionPlot]],
PlotLegends -> swl]]
```

Example:

```
mspmod[{x^3 - y^2 > 2, x^2 + y^3 > 3,
x^3 - y^2 > 2 && x^2 + y^3 > 3}, {-3, 3}, {-3, 3}, 50, 50, {Red,
Green, Yellow}]
```

3

Please see the answer here: Mesh inside Plot legend

– rm -rf – 2014-02-09T04:49:26.737