I have a huge table of x,y data. Looks like this:

\addplot+[mark size=0.2]table[row sep=\\,x = add,y = mul]{add mul \\
2.   0.32 \\
6.0  0.23 \\
7.0  0.23 \\
8.0  0.13 \\
12.0 0.17 \\
23.0 0.14 \\
50.0 0.09 \\

However is you can see in the figure, the data is pretty dense. I just need to smooth out all the data points so the three different lines are visible distinctly from each others. The first thought that came to my mind is moving average. But I couldn't find how to do that with pgfplots.

The figure

  • 2
    I'm fairly sure there is no prebuilt way of doing that, and it might be easier to do it in an external application (e.g. Python with pandas) and write out a .csv file. Could be possible with pgfplots alone, I don't know, if you're willing to try lualatex it would certainly be possible there (see e.g. tug.org/TUGboat/tb35-1/tb109montijano.pdf for some examples of combining Lua and pgfplots). – Torbjørn T. May 20 '16 at 10:31
  • I agree with TorbjørnT., that there is no built-in solution in PGFPlots. But at <opensourceforu.com/2016/06/plotting-with-latex>, especially in section "Smoothing: an example of interacting with Scilab" (and resulting Figure 5) is described a workaround. – Stefan Pinnow Oct 23 '16 at 11:57
  • Just in case you, or anyone else seeing this, is interested: tex.stackexchange.com/questions/109457/… – Torbjørn T. Oct 24 '19 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.