2

When plotting fast oscillating data from a table with pgfplots, an overshoot of the curve was observed (due to interpolation?). If the same data was plotted using Matlab, no overshoot occurred. The same phenomenon was observed when plotting a fast oscillating function, instead of data from a table. Here is the minimum working example, where a chirp signal sin(x^2) is displayed:

enter image description here

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[xmin=0,xmax=150,ymin=-1.2,ymax=1.2,width=0.4\textwidth,height=0.3\textwidth]
    \addplot[
        thick,
        mark=none,
        domain=0:150,
        samples=1000,
    ] {sin(x^2)};
\end{axis}
\end{tikzpicture}

\end{document}

The figure was compiled using PDFLaTeX, from the MiKTeX distribution. One can note that the curve overshoots 1 in absolute value, starting around the abscissa x=50. How to remove these spurious peaks?

2
  • 2
    They are called miters. They get longer for acute angles. – percusse Jul 4 '17 at 13:31
  • 4
    Add this after \usepackage{pgfplots}: \pgfplotsset{every axis/.append style={line join=round, line cap=round}} – AlexG Jul 4 '17 at 14:44

Browse other questions tagged or ask your own question.