I have a problem concerning pgfplots and large datasets. I have the following minimal example:


\pgfplotsset{plot coordinates/math parser=false}


%\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzset{external/remake next}

\tikzset{external/remake next}

\tikzset{external/remake next}


The three files lwXX.tikz can be found here (also the .tex-file and the result).

Since I know there are problems concerning the memory in LaTeX, I use the externalization option and the parameter -buf-size=5000000 while compiling the file (I also tried to compile the figures using LuaLaTeX which can be done by uncommenting the comment, but the output did not change)

My problem now is, there are unwanted spikes in the output. I illustrated it in a picture, which can be seen here

here http://www.uni-ulm.de/~pqa62/pgfplots_large_dataset/illustration.png.

The three figures are plotted using different line widths in the TikZ file. If you zoom in in the .pdf-file you will see what I mean. Also in the second pictures some spikes will then appear.

Does anybody know, where these errors come from and how to avoid them? I can hardly reduce the size of the dataset, since the underlying data is a sinusoidal function multiplied with some other function and one period of the sinusoidal is already only made up of approximately 14 datapoints. I don't want to reduce this number any further.

  • When I run diff on the three tikz files, the differences between the files are only in the values of the line width parameters. Is this as it should be? – A.Ellett Jun 12 '13 at 17:19
  • Originally I had even bigger files, where I definitely needed to increase the buffer. But I tried it again and you are right, for this example I actually do not need to increase it. and for the different files, I intentionally only changed the line width (what I already wrote under the figure) to illustrate the different outcome. – bene Jun 12 '13 at 17:29
  • 1
    Please attach pictures to the post in the future. :-( Link rip. – Andriy Drozdyuk Jul 16 '17 at 18:24

This problem appears because the corners on the lines are really tight, causing the lines to overshoot when a sharp line join is used (see How can I prevent pgfplots from rendering lines incorrectly when I use "no markers"?). You can fix this by using line join=round. to apply that option to all your plots without having to change all the files, you can simply add the following to your document:

    every axis plot post/.style={
        line join=round

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.