Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I plot tabular data wherein none of the y-values of the data go above 1.0. In the resulting plot, however, there are a couple of peaks that go beyond 1.0, giving a false impression about those data points: enter image description here

This is not visible when I plot with marks, but I need to use "no marks" because it is otherwise far too busy (80 points in a small plot).

How can I prevent this?

Update: Per Jake's request, here's a minimal example that shows the described behaviour:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{figure}[ht]
        \begin{tikzpicture}
            \begin{axis}[no markers, grid=major]
                \addplot coordinates{(0, 0.0000000000)
                                     (1, 0.8823529412)
                                     (2, 0.8750000000) 
                                     (3, 1.0000000000) 
                                     (4, 0.8666666667)
                                     (80, 0.0000000000)}[thick];
            \end{axis}
        \end{tikzpicture}
    \end{figure}
\end{document}

The problem is less pronounced when I don't make my lines thick, but it is still there (and I want thick lines).

share|improve this question
    
I tried reproducing this, but didn't succeed: For me, the sharp corners are always correctly drawn as bevel joins. Could you post a full minimal example that shows the described behaviour? –  Jake Apr 13 '11 at 6:16
    
@Jake: Yes; thanks for taking a look. –  shino Apr 13 '11 at 13:47
add comment

1 Answer

up vote 5 down vote accepted

There are a couple of ways you can avoid this: You can either tell pgfplots to use round corners or beveled corners for all corners by supplying the option line join=round or line join=bevel to the axis or to individual plots, or you can lower the threshold for when the join type changes from mitered to beveled by using miter limit=<value> (10 is the default).

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{figure}[ht]
        \begin{tikzpicture}
            \begin{axis}[no markers,grid=major,every axis plot post/.append style={thick}]
                \addplot  coordinates{(0, 0.0) (0, 0.9) (1, 0.9) (2, 1) (3, 0.9) (80, 0)};
                \addplot +[line join=round] coordinates{(0, 0.0) (0, 0.9) (2, 0.9) (3, 1) (4, 0.9) (80, 0)};
                \addplot +[line join=bevel] coordinates{(0, 0.0) (0, 0.9) (3, 0.9) (4, 1) (5, 0.9) (80, 0)};
                \addplot +[miter limit=5] coordinates{(0, 0.0) (0, 0.9) (4, 0.9) (5, 1) (6, 0.9) (80, 0)};
            \end{axis}
        \end{tikzpicture}
    \end{figure}
\end{document}

different ways of joining lines

share|improve this answer
    
Worked like a charm, thanks a lot! :) –  shino Apr 13 '11 at 15:42
    
If you don't mind, I will copy-paste this example to the pgfplots manual... –  Christian Feuersänger Apr 21 '11 at 19:25
    
@christian: By all means, please do! –  Jake Apr 22 '11 at 11:01
add comment

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.