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.
Thanks in advance.
i=1in the variable list of theModule. AddContourStyle -> Directive[Specularity[], ColorData[97][i++]]at the end of theContourPlot3D. This will create a new colour for each iteration of theTable.ColorData[97]is the default colour function,ColorData[97][i]is a different colour for eachi(well, it probably repeats after a while).Specularity[]resets the ugly white-shiny look added byContourPlot3D– Szabolcs Oct 05 '17 at 14:02ColorData[97][++]withmyColorList[[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 05 '17 at 14:24ContourPlot3D? You can replace the>=with==yourself. Then you can give a specificContourStyleto each one. – Szabolcs Oct 05 '17 at 14:52