2
$\begingroup$

How does one change the style of the labels of a BoundaryMesh region? For example it would be great to be able to make vertex labels to be red, edge labels blue, and face labels black, or even make the labels bold, or larger etc. This would make it easier to see all of the indices on a given mesh, which is helpful when writing code to do calculations on the mesh.

Using the built in functionality of HighlightMesh[] one can label mesh elements according to their index i.e.

a = BoundaryDiscretizeRegion[Ball[{0, 0, 0}, 1], 
   MaxCellMeasure -> {"Length" -> 1}, PrecisionGoal -> 1];
HighlightMesh[a, {Labeled[0, "Index"]}]

However when I try to change the style of the label either all labels disappear or the vertices themselves change their colour on the mesh. The result of HighlightMesh[a, {Style[Labeled[0, "Index"], Red]}] can be seen below:

example

Any help would be greatly appreciated.

$\endgroup$
  • $\begingroup$ Looks like is a bug, that HighlightMesh[a, {Labeled[0, "Index", LabelStyle -> Red]}] doesn't work. The documentation on Labeled would lead me to believe that it should. $\endgroup$ – Jason B. Feb 20 '17 at 15:24
2
$\begingroup$

Here's one way:

a = BoundaryDiscretizeRegion[Ball[{0, 0, 0}, 1], 
   MaxCellMeasure -> {"Length" -> 1}, PrecisionGoal -> 1];
HighlightMesh[a, {Labeled[0, "Index", Automatic, 
   Style[#, Red, Bold] &], 
  Labeled[1, "Index", Automatic, Style[#, Blue, Italic, 15] &]}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks. I need to do some more testing and I will let you know how it works. $\endgroup$ – Dunlop Feb 20 '17 at 16:13
  • $\begingroup$ After quickly checking this seems to work well for vertices and edges, but for some reason the face labels seem to be displaced i.e. compare HighlightMesh[a, {Labeled[2, "Index"]}]with HighlightMesh[a, {Labeled[2, "Index", Automatic, Style[#, Blue] &]}]. $\endgroup$ – Dunlop Feb 20 '17 at 16:21
  • 2
    $\begingroup$ HighlightMesh[a, {Labeled[2, "Index", "Centroid", Style[#, Blue] &]}] will work $\endgroup$ – halmir Feb 20 '17 at 17:33

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.