Problem in highlighting regions in RegionPlot3D

In the following RegionPlot3D

  f1 = Sin[x y]; f2 = x + y; f3 = x + z;
RegionPlot3D[
f1 < 1 && f2 < 1 && f3 < 1, {x, 0, 1}, {y, 0, 1}, {z, 0, 1},
PlotPoints -> 35, PlotRange -> All, AxesLabel -> Automatic,
PlotLegends -> Automatic]


I want to understand how to highlight (kind of "PlotLegend") the regions f1, f2, f3.

• You might be able to adapt the solution here so that the pieces are colored the way you want them. Commented Jul 22, 2022 at 15:33
• Since f1<=1 always true, maybe you wan to set f1 < 1/8 for example. Commented Jul 23, 2022 at 0:38

\$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global*"]

f1 = Sin[x y]; f2 = x + y; f3 = x + z;

data1 = Transpose[{
(Rest@
Subsets[
{f1 < 1/8, f2 < 1/2, f3 < 1/2},
3]),
Rest@
Subsets[
Opacity[0.5, ColorData[97][#]] & /@
Range[3],
3]}];

data2 = ReplacePart[#, 1 -> And @@ #[[1]]] & /@ data1;

data = Drop[Riffle[data1, data2], {1, 5, 2}];

Partition[
Insert[RegionPlot3D[Evaluate@#[[1]],
{x, 0, 1}, {y, 0, 1}, {z, 0, 1},
PlotStyle -> #[[2]],
PlotRange ->
{{0, 1}, {0, 1}, {0, 1}},
PlotPoints -> 50,
MaxRecursion -> 7,
PlotRange -> All,
AxesLabel -> Automatic,
PlotLabel ->
StringForm["", #[[1]]]] & /@
data,
SpanFromLeft, 4],
2] // Grid


• Thanks, but there is some problem. When I run, it shows "{Sin[x\ y]<1/8,x+y<1/2} must be a Boolean function" (I am using version 11.3 on Windows 19). Could you write more simply what data1, data2 and data mean? And what Evaluate@#[[1]] stands for? Commented Jul 27, 2022 at 12:46
• The error message "{Sin[x\ y]<1/8,x+y<1/2} must be a Boolean function" appears to indicate an extraneous backslash character was inserted. Did you copy and paste from above or retype the input? The RegionPlot3D expression is being mapped onto the list data. The # is an element of the list data. The element of the list is itself a list. #[[1]] is the fist part (element) of that sublist. Evaluate@#[[1]] is equivalent to Evaluate[#[[1]]] If you don't recognize an operator or function, highlight it in Mathematica and press F1` for help. Commented Jul 27, 2022 at 15:55