Thickness destroys Dashing for some platforms/versions

I can reproduce the problem on OS X with versions 10.0-11.1.

It seems to happen because the default line cap setting is CapForm["Square"]. This means that each line segment making up the dashed line will visually extend beyond their endpoints.

A fix that works on OS X is using

CapForm["Butt"]

which ensures that the line segments only extend to their endpoints.

Plot[{Cos[x], Sin[x]}, {x, 0, 2 Pi}, 
 PlotStyle -> {{CapForm["Butt"], Green, Thickness[0.02], 
    Dashing[Tiny]}, {Red, Thickness[Large]}}]

Mathematica graphics

This fixed the problem on-screen, and in PDF or EPS export.

This answer is only for OS X. I expect that Mathematica may behave differently on other operating systems.


I got this response from Wolfram Tech Support that is also a good fix (but not as good as Szabolcs'), though I can't say I see the purpose of such a design choice:

"This is as designed. If you imagine an infinitely thin line extending from pt1 to pt2 and now add thickness in ALL directions you will find that at the end of the line segments the added thicknesses will interfere with each other. You can get around this using Dashing.

Graphics[{Dashing[{.02, .04}], Thickness[.02], 
  Line[{{0, 0}, {1, 1}}]}]

This will work in options such as PlotStyle."