Framed[Show[Region[ConvexHullMesh[{P0,P1,P3},MeshCellStyle -> {2 -> Opacity[0.5, Red]}],PlotRange->{{-1.1,1.1},{-1.1,1.1}},Axes->True,LabelStyle ->{14,Bold}, ImageSize->Medium],Region[ConvexHullMesh[{P0,P3,P4},MeshCellStyle -> {2 -> Opacity[0.5,Red]}], ImageSize->Medium],Graphics[Text[Style["Cone 1",20,Bold],{0.7,1}]]]]

I have this code where I show in a single plot the intersection of two convex hull. Now I know it is possible to change the color of individual hull's by changing the MeshCellStyle command. But is it also possible to change the color of the intersecting region without major changes in the code? This will help my reader to better recognize the intersection region when I plot many convex hull in a single plot. Thank you


1 Answer 1

chm1 = ConvexHullMesh[{P0, P1, P3}];
chm2 = ConvexHullMesh[{P0, P3, P4}];

You can use RegionIntersection to get the intersection:

intersection = RegionIntersection[chm1, chm2];

and RegionPlot all three regions with different colors using the option PlotStyle:

Framed[RegionPlot[{chm1, chm2, intersection}, 
  PlotStyle -> {Opacity[.5, Red], Opacity[.5, Blue], Opacity[1, Yellow]}, 
  PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, 
  Axes -> True, Frame -> False, LabelStyle -> {14, Bold}, 
  ImageSize -> Medium, 
  Epilog -> Text[Style["Cone 1", 20, Bold], {0.7, 1}]]]

enter image description here

  • $\begingroup$ Thanks a lot. Very intelligent answer. $\endgroup$
    – Epsilon
    Commented Apr 19, 2020 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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