2
$\begingroup$

I'm using the command Show to overlay the following three regions:


r1 = RegionPlot[ 5/2 y + 3 x <= 3 && y < 2/3 && 5/2 y + x <= 2, {x, 0, 1}, {y, 0, 1}]

r2 = RegionPlot[ y < 13/12 - 13/12 x && y < 13/24 , {x, 0, 1}, {y, 0, 1}]

r3 = RegionPlot[y <= 1 - x && y < 2/3 , {x, 0, 1}, {y, 0, 1}]

Show[r1, r2, r3]


The problem is that I can't label them in the final picture and I'd like to change the colors as well to distinguish them more clearly. If possible, I'd like to plot some special points on this picture (like a few of the corners). Is there a "simple" way of doing that?

I'd appreciate any input that you may have. Thanks!

$\endgroup$
1
  • $\begingroup$ You get labels and distinct color by combining the equations in one RegionPlot and using PlotLegends option: RegionPlot[{eqs1, eqs2, eqs3}, {x, 0, 1}, {y, 0, 1}, PlotLegends -> {"1", "2", "3"}]. $\endgroup$
    – Coolwater
    Commented Oct 6, 2020 at 19:55

2 Answers 2

2
$\begingroup$

Something like this?

r1 = RegionPlot[
   5/2 y + 3 x <= 3 && y < 2/3 && 5/2 y + x <= 2, {x, 0, 1}, {y, 0, 
    1}, PlotStyle -> {Opacity[0.2], Yellow}, 
   PlotLabels -> Placed["First region", {.8, .3}]];
r2 = RegionPlot[
   y < 13/12 - 13/12 x && y < 13/24, {x, 0, 1}, {y, 0, 1}, 
   PlotStyle -> {Opacity[0.3], Green}, 
   PlotLabels -> Placed["Second region", {.4, .4}]];
r3 = RegionPlot[y <= 1 - x && y < 2/3, {x, 0, 1}, {y, 0, 1}, 
   PlotStyle -> {Opacity[0.5], LightRed}, 
   PlotLabels -> Placed["Third region", {.2, .7}]];
Overlay[{r1, r2, r3}]

enter image description here

$\endgroup$
1
  • $\begingroup$ That is perfect, thanks! Is it also possible to plot some of the corners with in the same code? For example, (1/2,13/24) and (1/2,3/5). $\endgroup$
    – ibr_
    Commented Oct 6, 2020 at 21:34
2
$\begingroup$
{a, b, c} = {5/2 y + 3 x <= 3 && y < 2/3 && 5/2 y + x <= 2, 
   y < 13/12 - 13/12 x && y < 13/24, y <= 1 - x && y < 2/3};
RegionPlot[{
  Callout[a, "a corner", {1/2, 3/5} + {.1, 0.3}, {1/2, 3/5}, 
   CalloutMarker -> "Arrow", Background -> Blue, 
   LabelStyle -> White],
  Callout[b, "b", {0.2, 13/24} + {0, 0.3}, {0.2, 13/24}, 
   CalloutMarker -> "Arrow"], 
  Callout[b, "b corner", {1/2, 13/24} + 0.3, {1/2, 13/24}, 
   Appearance -> "Balloon", Background -> Green, LabelStyle -> Gray],
  Callout[c, "c", Appearance -> "Arrow", Background -> Red, 
   LabelStyle -> White]
  },
 {x, 0, 1}, {y, 0, 1}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.