0
$\begingroup$
func={x+y+z<1&&x+y<z,x+y+z<1&&x+z<y,x+y+z<1&&y+z<x,x+y+1<z,x+z+1<y,y+z+1<x};

framelabels = TraditionalForm /@ {Abs[Subscript[u, 1]], 
   Abs[Subscript[u, 2]],Abs[Subscript[u, 3]]};

RegionPlot3D[func,{x,0,2},{y,0,2},{z,0,2},AxesOrigin->{0,0,0},Axes->True,AxesStyle -> Thick,AxesLabel->framelabels,ImageSize->Large,LabelStyle -> {14, Bold, Black},Mesh->None,PlotStyle->{Red,Blue,Purple,Brown,Green,Yellow},PlotPoints->100]

I used the above code to generate a 3D plot. But I want to add label to different regions in this plot by using PlotLabels but it is not working in a 3D plot. Although I used it for 2D RegionPlot and it worked well as shown in the diagram below enter image description here.

The exact code for the 2D plot above is:

funcs = {x < 1 && y < 1 && x + 2 (x y)^(1/2) < 1, 
    y < 1 && x > 1 && 1/x + 2 (y/x)^(1/2) < 1, 
    ((1/(x y))^(1/2) + (x/( y))^(1/2))^(2) < 4 , 
    x y < 1/4 && y > 1 && x + 2 (x y)^(1/2) < 1, 
   y/ x < 1/4 && y > 1 && 1/x + 2 (y/x)^(1/2) < 1};

labels = TraditionalForm[Subscript[\[ScriptCapitalR], #]]&/@ Range[Length[funcs]];

framelabels = TraditionalForm /@ {Abs[Row[{Subscript[u, 1], "/", Subscript[u, 3]}]], 
   Abs[Subscript[u, 2]]};


RegionPlot[funcs, {x, 0, 9}, {y, 0, 3}, 
 PlotLabels -> Join[Placed[#,Center] & /@ labels[[;;3]],
   {Placed[labels[[4]], {{.1,1.4}, {10,.9}}], Placed[labels[[5]], Center]}], 
 LabelStyle -> {15, Bold, Black}, PlotPoints -> 100, 
 Axes -> True, Frame -> True, FrameLabel -> framelabels, 
 RotateLabel -> False, FrameStyle -> Directive[Black, 12],  
 PlotStyle -> {Red, Green, Cyan, Yellow, Purple}]

As you can see the above code I used PlotLabels inside PlotRegion but when I put it inside PlotRegion3D it shows error. So is it not possible for 3D plots in Mathematica or is there any other option specific to the 3D plot?

Thank You.

$\endgroup$
1
$\begingroup$

Edit your question's title to match your question.

PlotLabels is not an option for RegionPlot3D.

Options[RegionPlot3D, PlotLabels]

(* Options::optnf: PlotLabels is not a known option for RegionPlot3D.

{} *)

Recommend that you use PlotLegends.

func = {x + y + z < 1 && x + y < z, x + y + z < 1 && x + z < y, 
   x + y + z < 1 && y + z < x, x + y + 1 < z, x + z + 1 < y, y + z + 1 < x};

framelabels = 
  TraditionalForm /@ {Abs[Subscript[u, 1]], Abs[Subscript[u, 2]], 
    Abs[Subscript[u, 3]]};

labels = Array[Subscript[ℛ, #] &, Length[func]];

The regions' centroids are at

pts = RegionCentroid /@ (ImplicitRegion[
       # && 0 <= x <= 2 && 0 <= y <= 2 && 0 <= z <= 2, {x, y, z}] & /@
     func);

Reduce the Opacity if you want to place labels at the centroids.

Show[
 RegionPlot3D[func, {x, 0, 2}, {y, 0, 2}, {z, 0, 2},
  AxesOrigin -> {0, 0, 0},
  Axes -> True,
  AxesStyle -> Thick,
  AxesLabel -> framelabels,
  ImageSize -> Large,
  LabelStyle -> {14, Bold, Black},
  Mesh -> None,
  PlotStyle -> (Opacity[0.3, #] & /@ {Red, Blue, Purple, Brown, Green, 
      Yellow}),
  PlotPoints -> 100,
  PlotLegends -> labels],
 Graphics3D[
  Text[Style[#[[1]], 18, Bold], #[[2]]] & /@ Transpose[{labels, pts}]]]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks a lot for the help. I have edited the title. It was my mistake. $\endgroup$ – Sumit Banik Apr 26 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.