TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

I draw a graph, but the red line does not appear to have the same width everywhere. For instance, between [a,b] it looks like it's thicker.




        \pgfplotsset{every axis plot/.style={line width=1pt}}
        \begin{axis}[x                 = 1cm,
                     y                 = 3cm,
                     axis x line       = bottom, 
                     axis y line       = center,
                     xmin              = -.5,
                     xmax              = 4,
                     ymin              = 0,
                     ymax              = 1,
                     enlarge x limits  = 0.05,
                     xlabel            = $y$, 
                     xlabel style      = {at={(axis description cs:1.05,0)}},
                     ylabel            = $p_X(y)$,
                     ylabel style      = {at={(axis description cs:-.1,1.05)}},
                     unbounded coords  = jump,
                     xtick             = {1,2.5},
                     ytick             = 0.5,
                     xticklabels       = {$a$,$b$},
                     yticklabels       = {$\frac{1}{b-a}$},
                     xticklabel style  = {anchor = base, yshift =-\baselineskip}]
         \addplot+[every mark/.append style = {mark size=1.5,fill=red}, mark indices = {3,4}, red] coordinates {(-.5,0)(1,0)(nan,nan)(1,.5)(2.5,.5)(nan,nan)(2.5,0)(4,0)};


share|improve this question
up vote 6 down vote accepted

The axis lines are clipping your plot by default hence adding clip=false option to your wonderfully indented code solves that issue.

enter image description here

share|improve this answer
Thanks a lot percusse, it solved my problem. – Oleg Jan 1 '13 at 19:20
I have had the same problem recently and indeed the clip=false was the solution but to me this behaviour doesn't make that much sense as if you use markers, the markers do not get clipped but the lines do. A Behaviour where only the points which coordinates are outside the defined plot area get clipped, but if it is only the line thickness for data point inside the plotting area, then it really should not get clipped. – ArTourter Jan 2 '13 at 1:58
@ArTourter You can also make the markers clipped via clip marker paths=true option. You can also play around with different layers so it's quite flexible. – percusse Jan 2 '13 at 2:05

Your Answer


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.