Skip to main content
1 of 5
hana
  • 2.6k
  • 6
  • 19

How to create a line with label in the middle or top?

Can anyone help me create a line with label like this? The label could be on the middle or top (just in case the distance between two points is too small).
The label always on top would also be good as well.

enter image description here

This is what I have so far.

lines[{a1_, a2_}, color_, label_] := Block[{},
  {Thickness[0.01], color, Line[{a1, a2}]}]

Graphics@lines[{{1, 2}, {3, 5}}, Red]
hana
  • 2.6k
  • 6
  • 19