16
$\begingroup$

Is there any way to change the thickness of line without changing the width?

For instance, the following example shows that as thickness increases, the white gap decreases. Is there any way to maintain the gap?

Show[
    ListPlot[{{0, 2}, {13.4, 2}}, PlotRange -> All, Joined -> True,
             Mesh -> None, PlotStyle -> {Gray, Thickness[0.01]}],
    ListPlot[{{14.7, 2}, {24, 2}}, Joined -> True, Mesh -> None,
             PlotStyle -> {Gray, Thickness[0.01]}]
]

thin lines with gap

Show[
    ListPlot[{{0, 2}, {13.4, 2}}, PlotRange -> All, Joined -> True,
             Mesh -> None, PlotStyle -> {Gray, Thickness[0.05]}],
    ListPlot[{{14.7, 2}, {24, 2}}, Joined -> True, Mesh -> None,
             PlotStyle -> {Gray, Thickness[0.05]}]
]

thick lines without gap

$\endgroup$
1
  • $\begingroup$ Could you please edit your post (edit link below it) and use the {} button on the toolbar to format it for readability? $\endgroup$
    – Szabolcs
    Mar 15, 2013 at 16:56

1 Answer 1

20
$\begingroup$

Use CapForm["Butt"] in PlotStyle to tell the system that the line must end exactly at the specified coordinates.

PlotStyle -> Directive[CapForm["Butt"], Gray, Thickness[0.05]]
$\endgroup$
1
  • $\begingroup$ Aha! This solved a problem of mine when I exported plots to pdf the thicker line went outside the frame slightly! Thanks! +1 $\endgroup$
    – s0rce
    Mar 15, 2013 at 18:47

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.