I would like to draw a line between two points and place a label "label" at its center, above the line. It would be also useful if this label remain parallel to the line when rotating the figure. What I have tried is the following:

MeshRegion[{{0, 0, 0}, {0, 0, 1}}, {Line[{1, 2}]}, 
 MeshCellLabel -> {1 -> Placed["label", "Above"]}]

but the directive "Above" does not seem to work. The command

MeshRegion[{{0, 0, 0}, {0, 0, 1}}, Line[{1, 2}], 
 MeshCellLabel -> {1 -> Placed["label", "Centroid"]}]

results in an undesired arrangement perpendicular to the line:

enter image description here

Furthermore, the absolute position retains while rotating the figure.


1 Answer 1


You may use "Rotate" on the text like e.g.:

p1 = {0, -1};
p2 = {-1, 1};
  Line[{p1, p2}],
  Rotate[Text["Label", (p1 + p2)/2 - 0.02 (p1 - p2)], 
   ArcTan @@ (p1 - p2), (p1 + p2)/2]

enter image description here


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.