Change appearance of ConvexHullMesh
While the answers provided so far are nice, it seems like there should be easier ways to achieve this. And there are, I will show two ways: 1) Keeping your ConvexHullMesh
as a BoundaryMeshRegion
object and (2 converting to a Graphics
object.
SeedRandom[0]
pts = RandomReal[4, {200, 3}];
chull = ConvexHullMesh[pts];
First we use HighlightMesh
with no need to recreate the MeshRegion
:
HighlightMesh[chull, {Style[0, Directive[PointSize[0.015], Red]],
Style[1, Thin, Blue], Style[2, Opacity[0.5], Yellow]}]
Note the use of Style
to style the various dimensions (0
for vertices, 1
for edges and 2
for facets. Also note that this object is still a BoundaryMeshRegion
and you can compute other nice mesh-related properties from it.
Now the Graphics
object approach.
Graphics3D[GraphicsComplex[MeshCoordinates[chull], {PointSize[0.02], Red,
MeshCells[chull, 0], Blue, MeshCells[chull, 1], Green, MeshCells[chull, 2]}],
Boxed -> False]
Note the use of the already available properties of the MeshRegion
. No need to use Show
here.
Show
allows you to convert to Graphics object:
Graphics[Show[ConvexHullMesh[p]][[1]] /. {Directive[x_] :>
Directive[{Red, EdgeForm[{Black, Thickness[0.02]}]}]}]
Or perhaps a little more interesting:
pts = RandomReal[{0, 1}, {50, 2}];
g = Graphics[{Red, PointSize[0.03], Point[pts]}];
ch = Show[ConvexHullMesh[pts]][[1]] /. {Directive[x_] :>
Directive[{Yellow, EdgeForm[{Black, Thickness[0.02]}]}]};
Show[Graphics[ch], g]
Why the above solution (
f@@q
) doesn't work?
Because a MeshRegion
is an AtomQ
.
How do I change the appearance of
ConvexHullMesh
?
Because
The convex hull region is the smallest convex region that includes the points
the computed and returned ConvexHullMesh
is of course correct. Because you are computing the convex hull, maybe it's because you are interested to show the input list of points and their convex hull. You can use Show
to combine directly a MeshRegion
with another Graphics
.
Maybe you are interested to DelaunayMesh
, related with but different from ConvexHullMesh
(returns a MeshRegion
instead of a BoundaryMeshRegion
).
p = {{0, 0}, {1, 0}, {1/2, 1/2}, {1, 1}, {0, 1}};
q = ConvexHullMesh[p];
{Show[q, Graphics@Point@p], HighlightMesh[DelaunayMesh[p], Style[0, Red]]}