4
$\begingroup$

When I read a paper, I found a image just like following:

enter image description here

I don't care about the real curve functions, I only want drawing like it. So I try to coding:

g1 = RegionPlot[y > 3 x^2, {x, 0, 1}, {y, 0, 1}, PlotStyle -> LightBlue, BoundaryStyle -> Directive[Orange]];
g2 = RegionPlot[y > 2 x^2, {x, 0, 1}, {y, 0, 1}, PlotStyle -> LightYellow, BoundaryStyle -> Directive[Red, Dashed], FrameStyle -> Directive[Black, 16]];
Show[g2, g1]

My questions are: 1. How to drawing the black frame like the first image? 2. Mesh option will achieve this grids effect? 3. Mesh->All will affect the BoundaryStyle option?

enter image description here

$\endgroup$
8
$\begingroup$
g1 = RegionPlot[y > 3 x^2, {x, 0, 1}, {y, 0, 1}, 
   PlotStyle -> Directive[EdgeForm[LightGray], LightBlue], 
   BoundaryStyle -> Orange];

g2 = RegionPlot[y > 2 x^2, {x, 0, 1}, {y, 0, 1}, 
   PlotStyle -> Directive[EdgeForm[LightGray], LightYellow], 
   BoundaryStyle -> Directive[Red, Dashed], 
   FrameStyle -> Directive[Black, 16]];

g3 = RegionPlot[True, {x, 0, 1}, {y, 0, 1}, PlotStyle -> None, 
   BoundaryStyle -> Directive[Thick, Black]];

Show[g2, g1, g3]

enter image description here

You can use a single RegionPlot to get the same picture:

RegionPlot[{y > 2 x^2, y > 3 x^2, True}, {x, 0, 1}, {y, 0, 1},
 FrameStyle -> Directive[Black, 16],
 PlotStyle -> {Directive[EdgeForm[LightGray], LightYellow], 
   Directive[EdgeForm[LightGray], LightBlue], None}, 
 BoundaryStyle -> {2 -> Directive[Orange], 
   1 -> Directive[Red, Dashed], 3 -> Directive[Black, Thick]}]

same picture

Alternatively, you can add the black rectangle using Epilog:

RegionPlot[{y > 2 x^2, y > 3 x^2}, {x, 0, 1}, {y, 0, 1},
 FrameStyle -> Directive[Black, 16],
 PlotStyle -> {Directive[EdgeForm[LightGray], LightYellow], 
   Directive[EdgeForm[LightGray], LightBlue]}, 
 BoundaryStyle -> {2 -> Directive[Orange], 1 -> Directive[Red, Dashed]}, 
 Epilog -> {EdgeForm[{Black, Thick}], FaceForm[], Rectangle[]}]

same picture

$\endgroup$
  • $\begingroup$ Thanks, the results are very similar. $\endgroup$ – zongxian Dec 4 '19 at 16:22
  • $\begingroup$ @zongxian notice the meshing is higher around only the overlapping portions, maybe that will help you. This is awesome publication level graphics @kglr!! $\endgroup$ – CA Trevillian Dec 5 '19 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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