\documentclass[a4paper]{article}

\usepackage{pgfplots}

\usetikzlibrary{external}
\tikzexternalize

\begin{document}
\begin{tikzpicture}
	\REPLACEMEHEREUSINGTHESCRIPT
\end{tikzpicture}
\end{document}

