I am plotting smoothed data curves by applying the smooth option to the according diagram curve like this:

\addplot[color=black, mark=none, smooth] table[x=time, y=measured, col sep=semicolon] {./data.csv};

I was using those plots internally only. However, since those should be used for a scientific publication in the future I need some information about the smoothing polynomial in order to back the plotting up a bit.

I had a look into both the pgfplots manual and the pgf/TikZ manual which do not seem to provide any further information about the used smoothing polynomial or algorithm.

So does anyone know which approach/algorithm is used to smooth the data before plotting?


1 Answer 1


Smoothing is not done globally hence there is no actual smoothing polynomial is used. Instead of connecting the consecutive points with line segments, a bezier curve is used to connect consecutive points in the parsed input stream with approx equal in out angles defined by the control points of the Bezier curves. Hence if there is a steep change between points you should expect overshoots/undershoots. This is also mentioned in the manual under smooth key.

You can see the actual code in pgflibraryplothandlers.code.tex file line 24. The \pgfplothandlercurveto macro definition is the actual algortihm.

In scientific publications, you should not alter the data with smooth keys for aesthetic reasons, or smoothen for a purpose with the provided actual code how it is done.

  • Thanks for the information, that explains a lot of anomalous behavior. There are better ways of smoothing than bezier curves. Hmmm.
    – JPi
    Feb 20, 2017 at 16:27
  • 2
    @JPi: It's worth keeping in mind that the smooth key is a TikZ key, not a PGFPlots key: this function was originally intended for drawing, not for smoothing data plots.
    – Jake
    Feb 20, 2017 at 17:24
  • @Jake It was intended for plots though hence the plot handler. Only in the regular paths there are very few points.
    – percusse
    Feb 20, 2017 at 18:05
  • How hard would it be to add one's own smoothing algorithm?
    – JPi
    Feb 20, 2017 at 18:07
  • @JPi Current one is also a smoothing algorithm. Depends on the complexity.
    – percusse
    Feb 20, 2017 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .