# Can I customize contourRegionPlot3D to choose a color for each face of my region?

In the (accepted) answer to this post, @SimonWoods gives an awesome alternative to RegionPlot3D that gives better definition to the faces and edges of the plotted regions. The code he introduces is

contourRegionPlot3D[region_, {x_, x0_, x1_}, {y_, y0_, y1_}, {z_, z0_, z1_},
opts : OptionsPattern[]] := Module[{reg, preds},
reg = LogicalExpand[region && x0 <= x <= x1 && y0 <= y <= y1 && z0 <= z <= z1];
preds = Union@Cases[reg, _Greater | _GreaterEqual | _Less | _LessEqual, -1];
Show @ Table[ContourPlot3D[
Evaluate[Equal @@ p], {x, x0, x1}, {y, y0, y1}, {z, z0, z1},
RegionFunction -> Function @@ {{x, y, z}, Refine[reg, p] && Refine[! reg, ! p]},
opts], {p, preds}]]


which can be implemented, for example, via

contourRegionPlot3D[
(x < 0 || y > 0) && 0.5 <= x^2 + y^2 + z^2 <= 0.99,
{x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Mesh -> None]


similarly to RegionPlot3D.

I'm interested in tweaking this so that I can choose a color for each face of my region. Can anyone figure out a way to do that?

One of the things the code above does is it generates each face lying on the region where each inequality is an equality, constrained to the region bounded by the other faces. Being rather new to Mathematica though, I cannot detect where this occurs, so I'm not sure where to begin experimenting.

Application: I'm using this to show a fundamental domain for a manifold, where certain sides are identified by isometries. I want to color pairs of identified faces the same color.

I like @ScottWoods way of plotting the regions the best out of everything I've found so far, but if there's an alternative way of assigning colors to a region defined by a system of inequalities, I'd also be interested to learn about that.

• Can you try this? Add i=1 in the variable list of the Module. Add ContourStyle -> Directive[Specularity[], ColorData[i++]] at the end of the ContourPlot3D. This will create a new colour for each iteration of the Table. ColorData is the default colour function, ColorData[i] is a different colour for each i (well, it probably repeats after a while). Specularity[] resets the ugly white-shiny look added by ContourPlot3D – Szabolcs Oct 5 '17 at 14:02
• @j0equ1nn - you can take Szabolcs's snippet and replace ColorData[++] with myColorList[[i++]] where you've predefined the list of colors, and are certain it has the same size as the list of inputs. – Jason B. Oct 5 '17 at 14:24
• Wouldn't it be easier to just plot these surfaces manually with ContourPlot3D? You can replace the >= with == yourself. Then you can give a specific ContourStyle to each one. – Szabolcs Oct 5 '17 at 14:52