7
$\begingroup$

One can color the interior of a region by ColorFunction. But how to color the exterior of a region of a RegionPlot (I want to change the standard white color to lets say red)? Whats the necessary command?

btw: Background is actually not what I'm looking for, as it colors the background even outside the PlotRegion!

$\endgroup$
4
  • $\begingroup$ ...but the white color is precisely the background! If you must have a different colorization without involving the background, make another RegionPlot[], this time of the negation of the original region function. $\endgroup$ Apr 10, 2016 at 12:46
  • $\begingroup$ ...a pitty. Negation was my primary idea too. However, applying a BoundaryStyle causes some troubles in my actual code than. $\endgroup$
    – Kay
    Apr 10, 2016 at 12:59
  • $\begingroup$ @J.M. so you are saying: it is not possible to adress both, interior and exterior of a region within RegionPlot ? $\endgroup$
    – Kay
    Apr 10, 2016 at 13:01
  • $\begingroup$ As far as RegionPlot[] is concerned, it will only generate primitives corresponding to points that satisfy the region function given, and nothing more. $\endgroup$ Apr 10, 2016 at 13:09

1 Answer 1

7
$\begingroup$

As JM suggested, you can plot the complement of the region you are interested in, and assign a color to that:

RegionPlot[{x^2 + y^2 <= 2, x^2 + y^2 > 2}, {x, -3, 3}, {y, -3, 3}, 
 PlotRangePadding -> None, PlotStyle -> {Red, Blue}]

Mathematica graphics

If the complement of your region cannot be readily expressed, or more in general for multiple regions, you can identify the plane as a region where (x,y) are real:

RegionPlot[{
   {x, y} ∈ Reals, 
   x^2 + y^2 < 3},
   {x, -3, 3}, {y, -3, 3}, 
   PlotRangePadding -> None, 
   PlotStyle -> {Blue, Directive[Red, Opacity[1]]}
]

Mathematica graphics

$\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.