A few simple shapes:
lowercover = RegionDifference[Rectangle[{-2, -2}, {2, 0}], Disk[{0, 0}, 1]];
uppercover = RegionDifference[Rectangle[{-2, 0}, {2, 2}], Disk[{0, 0}, 1]];
square1 = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}];
square2 = Polygon[{{0.5, 0}, {1.5, 0}, {1.5, 1}, {0.5, 1}}];
When I do the following, Show ignores color options (the squares show as black) in the second and third objects:
Show[
Plot[None, {x, -2, 2}, PlotRange -> {{-1.05, 1.05}, {-1.05, 1.05}}],
Region[square1, BaseStyle -> {FrontFaceColor -> Blue}],
Region[square2, BaseStyle -> {FrontFaceColor -> Green}]]
Yet when I try this other example, Show honors the color options (shows blue and green) in the second and third objects:
Show[
Plot[None, {x, -2, 2}, PlotRange -> {{-1.05, 1.05}, {-1.05, 1.05}}],
Region[uppercover, BaseStyle -> {FrontFaceColor -> Blue}],
Region[lowercover, BaseStyle -> {FrontFaceColor -> Green}]]
Why is the behavior different?
(This is on 11.2)
ADDENDUM: The answers below are very helpful but I wanted to point out one one other surprising outcome:
blank = Graphics[{}, PlotRange -> {{0, 2}, {0, 1}}];
a = Polygon[{{0, 0}, {2, 0}, {2, 1}, {0, 1}}];
b = Polygon[{{1, 0}, {2, 0}, {2, 1}, {1, 1}}];
c = Polygon[{{-0.36, 0.21}, {-0.36, -0.21}, {0, -0.53}, {0.64, -0.37}, {0.64, 0.37}, {0, 0.53}}]
d = Polygon[{{-0.42, 0.24}, {-0.42, -0.24}, {0, -0.56}, {0.58, -0.33}, {0.58, 0.33}, {0, 0.56}}]
Show[blank, Region[RegionDifference[a, b], BaseStyle -> {FrontFaceColor -> Green}]]
Show[blank, Region[RegionDifference[c, d], BaseStyle -> {FrontFaceColor -> Green}]]
The first Show takes the color as a directive whereas the second takes it as an option and overrides it. Now, while this is surprising, the reason is pretty clear if you just evaluate the following:
RegionDifference[a, b]
RegionDifference[c, d]
The former returns a Boolean region while the latter returns a Polygon, and that's presumably why we get different outcomes. At one point, they both returned Boolean regions (or something equivalent), but I believe the update in RegionDifference for 11.2 has made the behavior diverge. So Show is very well-behaved. RegionDifference is still a a bit of a mystery to me!




Show[Graphics[{}, BaseStyle -> Orange, PlotRange -> 2], Region[square1, BaseStyle -> {FrontFaceColor -> Blue}], Region[square2, BaseStyle -> {FrontFaceColor -> Green}]], and compare with the version withuppercoverandlowercover. – J. M.'s missing motivation Mar 23 '18 at 07:16BaseStyleforRegionis not only a final'sGraphics'options but is also passed inside the structure. And the way it is used next toPolygondiffers whether you useRegionDifferenceor simple region.Showstill does not care about subsequent options. ButRegionhascolorDirectives, polygonstructure inside. See remark aboutPlotStyle/PlotMarkersin linked answer. – Kuba Mar 23 '18 at 07:16