# Pgfplots - large plot - TeX capacity exceeded

I have a following code, which is supposed to generate some output and one large plot from the file data5.csv:

\documentclass[a4paper, landscape]{article}

\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{underscore}
\usepackage{filecontents}

\makeatletter
\pgfplotsset{compat=1.13}
\makeatother

\begin{document}

\title{ Solve_RegCG_singular_dom_itersolver.cpp:110 }
\date{\today}
\maketitle
\pagebreak

\section{Lumped Preconditioner and SPDS (sparse-sparse)}

\textbf{CG Solver Overall Evaluation}
\begin{itemize}
\item Default: 4207.879395 J (24th, 2500000Hz)
\item Optimal: 4207.879395 J (24th, 2500000Hz)
\item Static savings: 0.0 J (0.00 \%)
\end{itemize}

\begin{tikzpicture}
\begin{axis}[
title={ 24_1200000_PREC1_SCHUR0.csv },
xlabel={ Number of samples },
ylabel={ Power [W] },
legend pos=outer north east,
xmajorgrids=true,
ymajorgrids=true,
grid style=dashed,
no markers,
width=24cm,
height=11cm,
cycle list name = color list
]
\addplot table [ x=ind, y=val, col sep=comma] {data5.csv};
\legend{ 0 }
\end{axis}
\end{tikzpicture}

\end{document}


Here is the link with the file data5.csv.

The problem is, that when I try to compile my code, I'm getting following error:

! TeX capacity exceeded, sorry [main memory size=7000000].
<argument> ...875e3],1Y9.1125e1],}{;1Y3.876e3\ETC.
l.46 ... x=ind, y=val, col sep=comma] {data5.csv};


As we can see, I've already tried to resize the memory according to this question, but, unfortunately, it isn't enough.

My other attempt was the use of externalization according to this question. I've changed my code like this:

\documentclass[a4paper, landscape]{article}

\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{underscore}
\usepackage{filecontents}

\usepgfplotslibrary{external}
\tikzexternalize

\makeatletter
\pgfplotsset{compat=1.13}
\makeatother

\begin{document}

\title{ Solve_RegCG_singular_dom_itersolver.cpp:110 }
\date{\today}
\maketitle
\pagebreak

\section{Lumped Preconditioner and SPDS (sparse-sparse)}

\textbf{CG Solver Overall Evaluation}
\begin{itemize}
\item Default: 4207.879395 J (24th, 2500000Hz)
\item Optimal: 4207.879395 J (24th, 2500000Hz)
\item Static savings: 0.0 J (0.00 \%)
\end{itemize}

\begin{tikzpicture}
\begin{axis}[
title={ 24_1200000_PREC1_SCHUR0.csv },
xlabel={ Number of samples },
ylabel={ Power [W] },
legend pos=outer north east,
xmajorgrids=true,
ymajorgrids=true,
grid style=dashed,
no markers,
width=24cm,
height=11cm,
cycle list name = color list
]
\addplot table [ x=ind, y=val, col sep=comma] {data5.csv};
\legend{ 0 }
\end{axis}
\end{tikzpicture}

\end{document}


And I'm compiling it with the command pdflatex -shell-escape. The problem is, I'm getting following error now:

! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "results-figure0" "\def\tikzexternalrealjo
b{results}\input{results}"' did NOT result in a usable output file 'results-fig
ure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enab
led system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it
is also named 'write 18' or something like that. Or maybe the command simply fa
iled? Error messages can be found in 'results-figure0.log'.


So, do you have any idea, what am I doing wrong? Or is it simply impossible to print a plot of this size just with pdflatex?

As you can see here, in other answers in SE, and as @JPi pointed out in a comment, LuaLaTeX can be the solution to you problem. In particular you have to run lualatex instead of pdflatex, with the same option (-shell-escape or -enable-write18). After the image has been externalized, you can fall back on pdflatex, as long as you don't introduce a new picture or change an existing one, in which case you have to run lualatex once more.