I would like to create a 2D graphics with lines, connecting points at integer coordinates and control the line's thickness expressed in the original coordinate system. E.g.

Line[{{0,0}, {1,0}, {2,1}, ...}]

such that the line has a thickness of 0.25 in terms of the coordinate system used for defining the points.

This should resemble the way you can define the radius of a Tube in 3D graphics.

Is this possible (in a convenient way)?

I know about Thickness (which uses plot-range-relative units) and AbsoluteThickness (which uses image-relative units). Neither is suitable, since the plot's range and size are not know in advance (they vary, e.g. inside a Manipulate).

This question Scaling edge thicknesses seems related, but the answers are not really good workarounds. Probably, Wolfram needs to add another option to solve this.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign $\endgroup$ – Dunlop Jan 26 '20 at 19:49
  • $\begingroup$ Can you show a mimimal example of some code where you can demonstrate what you have tried? Especially to show what doesn't work? This would help others understand your problem $\endgroup$ – Dunlop Jan 26 '20 at 19:50

If you want round corners, StadiumShapeis a possibility :

data = {{0, 0}, {1, 0}, {2, 1}}
Graphics[StadiumShape[#, 0.25] & /@ Partition[data, 2, 1]]  

enter image description here enter image description here

  • $\begingroup$ Good suggestion. I had never heard of StadiumShape (apparently, in 3D there is also CapsuleShape; you can, however ,accomplish that already through Tube with CapForm["Round"]). It would have been nice if Mathematica would show StadiumShape on the reference page for Line under 'See Also'. It is a bit unfortunate that StadiumShape is restricted to single line segments, but mapping it over a partition is not a big deal. Thanks. $\endgroup$ – Tom Verhoeff Jan 27 '20 at 12:49

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.