1
$\begingroup$

I'm trying to put a common legend for two-row RegionPlot. However, I haven't been able to get the colors in the legend right:

ra = RegionPlot[{y >= x^2 - 4 , y >= x^2 - 4 && y <= 0 }, {x, -10, 
   10}, {y, -10, +10}]

rb = RegionPlot[{y >= x^2 - 16 , y >= x^2 - 16 && y <= 0 }, {x, -20, 
20}, {y, -20, +20}]

Legended[GraphicsRow[{ra, rb}, Spacings -> Scaled[0.4], 
  Epilog -> Inset["Plot Title", Scaled[{0.5, 0.95}]]], 
 SwatchLegend[{Blue, Orange}, {"label1", "label2"}]]


Legended[GraphicsRow[{ra, rb}, Spacings -> Scaled[0.4], 
  Epilog -> Inset["Plot Title", Scaled[{0.5, 0.95}]]], 
 SwatchLegend[{LightBlue, LightOrange}, {"label1", "label2"}]]

I've also tried to change the colors of the regions. However, as far as I could tell, the declared color applied to the boundaries; the interior was a shade lighter, something I couldn't reproduce in the legend. Any ideas on how to address the problem?

$\endgroup$

1 Answer 1

2
$\begingroup$

How about this one?

ra = RegionPlot[{y >= x^2 - 4, y >= x^2 - 4 && y <= 0}, {x, -10, 
        10}, {y, -10, 10}, PlotStyle -> {Blue, Orange}, 
       BoundaryStyle -> None];
    rb = RegionPlot[{y >= x^2 - 16, y >= x^2 - 4 && y <= 0}, {x, -10, 
        10}, {y, -18, 10}, PlotStyle -> {Blue, Orange}, 
       BoundaryStyle -> None];
    Legended[Labeled[Multicolumn[{ra, rb}], 
      Style["Plot Title", 15, Bold, FontFamily -> "Helvetica"], Top], 
     SwatchLegend[{Blue, Orange}, {"label1", "label2"}]]

enter image description here

$\endgroup$
1
  • $\begingroup$ It did work! Now, although my application is much more convoluted, this MWE captures the fact that each region is a subset of another. Thus, anyone interested in using this approach should start RegionPlot from the largest set, and then proceed all the way towards the smallest. The order matters here. $\endgroup$
    – Ararat
    May 18, 2021 at 18:09

Your Answer

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

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