2

I got the following code:

\documentclass[tikz,border=2pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\usepackage{animate}
\usepackage{fp}
\newcommand*\tdist[1]{
\begin{tikzpicture}
  \begin{axis}[%
      xlabel =$q$,
      ylabel =$d$,
      xtick={-6,-4,...,6},ytick={.05,.1,...,.45},
      height=7cm, width=7cm,
      axis lines*=left,
      xmin = -6, xmax = 6,
      ymin = 0, ymax = .41,
      every y tick label/.append style  =
        { 
          /pgf/number format/.cd,
           precision = 2, 
           fixed zerofill,
           fixed
        },/pgf/number format/.cd,
        use comma]
    \def\k{#1}
    \addplot+[mark={},very thick, draw=cyan!80] gnuplot[raw gnuplot] {%
       plot [-6:6][-6:6] gamma(.5*(\k+1))/(sqrt(\k*pi)*gamma(.5*\k))*((1+x^2/\k)^(-.5*(\k+1)))};
  \end{axis}
\end{tikzpicture}
}
\begin{document}
\begin{animateinline}[controls,loop,palindrome]{12}
  \multiframe{72}{k=0+20}{
    \tdist{\k}
    }
    \end{animateinline}
\end{document}

It compiles and gives no errors, but sucks up one CPU core completely and never finishes. What's going wrong?

1010011010
  • 6,357

1 Answers1

1

Move tikz into package loading format. Don't put tikz in the class option when standalone is used. Since gnuplot is involved use xelatex -shellescape (MiKteX) to compile. Also please see info here Missing endgroup in animation

enter image description here

Code

\documentclass[border=2pt]{standalone}
\usepackage{tikz,pgfplots}
\usetikzlibrary{calc}
\usepackage{animate}
\usepackage{fp}
\newcommand*\tdist[1]{
\begin{tikzpicture}
  \begin{axis}[%
      xlabel =$q$,
      ylabel =$d$,
      xtick={-6,-4,...,6},ytick={.05,.1,...,.45},
      height=7cm, width=7cm,
      axis lines*=left,
      xmin = -6, xmax = 6,
      ymin = 0, ymax = .41,
      every y tick label/.append style  =
        { 
          /pgf/number format/.cd,
           precision = 2, 
           fixed zerofill,
           fixed
        },/pgf/number format/.cd,
        use comma]
    \def\k{#1}
    \addplot+[mark={},very thick, draw=cyan!80] gnuplot[raw gnuplot] {%
       plot [-6:6][-6:6] gamma(.5*(\k+1))/(sqrt(\k*pi)*gamma(.5*\k))*((1+x^2/\k)^(-.5*(\k+1)))};
  \end{axis}
\end{tikzpicture}
}
\begin{document}
\begin{animateinline}[controls,loop,poster=last]{12}
  \multiframe{72}{ik=0+1}{
    \tdist{\ik}
    }
    \end{animateinline}
\end{document}
Jesse
  • 29,686