Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If one plots a filled line plot such as, for example, the one produced by

ListLinePlot[{{{0, 0.6}, {0.5, 0.6}}, {{0.5, 0.3}, {1, 0.3}}}, 
    Filling -> Axis, PlotStyle -> AbsoluteThickness[10],
    AspectRatio -> Automatic, PlotRange -> {Automatic, {0, 0.8}},
    PlotRangePadding -> None]

the ends of the plot's lines have a rather noticeable "overhangs" beyond the fill regions below. How can I make this line be flush with the fill?

share|improve this question
up vote 6 down vote accepted

What you're seeing are the ends of the lines or the "caps" and because of the high thickness that you've specified, its presence is obvious. The solution here is to add CapForm -> None to the PlotStyle, which should give you the following plot.

The following example shows the effect of the caps more clearly:

With[{caps = {None, "Butt", "Round", "Square"}}, 
    Graphics[
        {
            {Opacity[0.3], CapForm[#], AbsoluteThickness[10], Line[{{0, 0}, {1, 0}}]},      
            {Red, Point[{{0, 0}, {1, 0}}]}
        }, 
        Axes -> {True, False}, AspectRatio -> 1/10, PlotRange -> {{-0.1, 1.1}, Automatic}, 
        ImageSize -> 300, PlotLabel -> ToString@#
    ] & /@ caps
] // Column

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.