# Single RegionPlot with different mesh functions

I have a set of inequations, which i'd like to plot as different regions with RegionPlot, which I defined by:

a = {-15 + p + q >= 0};
b = {4 p + q, 4 q + p, 20 - p, -10 + 5 q};
regions = Table[And[Not @@ a, And @@ (b <=  i // Thread)], {i, b}];


Then I'm plotting them like this:

RegionPlot[{a, regions}, {p, 0, 10}, {q, 0, 10},
FrameLabel -> {p, q}, MaxRecursion -> 3,
MeshFunctions -> {#1 + #2 &, #1 &}, Mesh -> 10,
MeshStyle -> {Orange, Green},
PlotLegends ->
SwatchLegend[Automatic, Prepend[b, "Infeasible: " And @@ a],
LegendMarkerSize -> {20, 20}]]


This produces:

Now, I'd actually like the mesh to only be applied to the first region (the one marked Infeasible), but instead it seems to be applied to the combinations of the regions plotted.

I know that it should be possible to Show, but then I don't see how I can combine the plots, create a proper Legend, which combines all parts of the plots. When I also to create a list of RegionPlots, I could not save the result of the RegionPlot (it simply showed up as Null).

Related questions, that don't quite answer my issue:

As a bonus, if you can show me at the same time how to make the line-spacing of the mesh independent of the size of the region, that would be greatly appreciated too.

• Your code produces a different outcome than the plot you posted: imgur.com/a/tk9bP. Also, the PlotLegends -> .... is irrelevant for the question asked. Finally, I'm quite surprised that MeshFunctions -> ConditionalExpression[{#1 + #2 &, #1 &}, -15 + #1 + #2 >= 0 &] (and its variations) doesn't work. – corey979 Sep 3 '17 at 19:13
• That's odd... even after clearing my globals, I still get a different plot than you. i.imgur.com/NOuHBEs.png As you see I'm using MM11.1 (on Windows 10). Were you under the impression that ConditionalExpression should have worked here? – Joost Sep 4 '17 at 9:31

One possibility is to draw the mesh in a second plot and draw it over the original one:

Show[
RegionPlot[
{a, regions}, {p, 0, 10}, {q, 0, 10},
FrameLabel -> {p, q},
MaxRecursion -> 3,
PlotLegends ->
SwatchLegend[Automatic, Prepend[b, "Infeasible: " And @@ a],
LegendMarkerSize -> {20, 20}]
],
RegionPlot[
a, {p, 0, 10}, {q, 0, 10},
MeshFunctions -> {#1 + #2 &, #1 &},
Mesh -> {Range[0, 20, 1]},
MeshStyle -> {Orange, Green}]
]


The code above also demonstrates how to achieve size independent mesh spacing. The only thing to what out for is that might you need to adjust the bounds of the Range to cover the values returned by your mesh functions.

• That is great. Somehow I messed up the Legends call, by adding it to the second one. – Joost Sep 4 '17 at 9:21