15
$\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$
  • $\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 '13 at 16:56
19
$\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]]
|improve this answer|||||
$\endgroup$
  • $\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 '13 at 18:47

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.